Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(workflows): let messaging onboarding start by picking channels (#124471)

Daniel Marchuk3aa29e176d9e
diff --git a/products/workflows/frontend/setupGuide/MessagingSetupMenuStatus.tsx b/products/workflows/frontend/setupGuide/MessagingSetupMenuStatus.tsx
index d036d779ce4e..62bfeb9c4513 100644
--- a/products/workflows/frontend/setupGuide/MessagingSetupMenuStatus.tsx
+++ b/products/workflows/frontend/setupGuide/MessagingSetupMenuStatus.tsx
@@ -16,7 +16,8 @@ export function MessagingSetupMenuStatus({ tab }: { tab: MessagingSetupTabKey })
const isDone = (key: string): boolean => steps.some((step) => step.key === key && step.done)
if (tab === 'channels') {
- if (isDone('domain')) {
+ const channelsDone = steps.some((step) => step.key === 'domain') ? isDone('domain') : isDone('channel')
+ if (channelsDone) {
return <IconCheckCircle className="text-success" />
}
return (
diff --git a/products/workflows/frontend/setupGuide/setupGuideSteps.test.ts b/products/workflows/frontend/setupGuide/setupGuideSteps.test.ts
index 974ec589b9bb..a58406c4eb9e 100644
--- a/products/workflows/frontend/setupGuide/setupGuideSteps.test.ts
+++ b/products/workflows/frontend/setupGuide/setupGuideSteps.test.ts
@@ -2,6 +2,8 @@ import { SetupGuideInputs, deriveSetupGuideSteps } from './setupGuideSteps'
const LOADED: SetupGuideInputs = {
emailChannels: [],
+ pushChannelCount: 0,
+ reachChannels: null,
optOutCategoryCount: 0,
emailTemplateCount: 0,
hasMessagingWorkflow: false,
@@ -9,7 +11,8 @@ const LOADED: SetupGuideInputs = {
describe('deriveSetupGuideSteps', () => {
test.each<[string, Partial<SetupGuideInputs>]>([
- ['channels', { emailChannels: null }],
+ ['email channels', { emailChannels: null }],
+ ['push channels', { pushChannelCount: null }],
['opt-out categories', { optOutCategoryCount: null }],
['email templates', { emailTemplateCount: null }],
['messaging workflows', { hasMessagingWorkflow: null }],
@@ -43,4 +46,29 @@ describe('deriveSetupGuideSteps', () => {
const steps = deriveSetupGuideSteps({ ...LOADED, ...inputs })
expect(steps?.filter((step) => step.done).map((step) => step.key)).toEqual(expectedDone)
})
+
+ test.each<[string, Partial<SetupGuideInputs>, string[]]>([
+ [
+ 'a push-only project skips the email steps',
+ { pushChannelCount: 1 },
+ ['channel', 'opt-outs', 'first-journey'],
+ ],
+ [
+ 'picking push only skips the email steps before anything is connected',
+ { reachChannels: ['push'] },
+ ['channel', 'opt-outs', 'first-journey'],
+ ],
+ [
+ 'a connected email channel keeps the email steps even when only push was picked',
+ { emailChannels: [{ verified: false }], reachChannels: ['push'] },
+ ['channel', 'domain', 'opt-outs', 'email-template', 'first-journey'],
+ ],
+ [
+ 'nothing picked or connected keeps the email steps',
+ {},
+ ['channel', 'domain', 'opt-outs', 'email-template', 'first-journey'],
+ ],
+ ])('%s', (_, inputs, expectedKeys) => {
+ expect(deriveSetupGuideSteps({ ...LOADED, ...inputs })?.map((step) => step.key)).toEqual(expectedKeys)
+ })
})
diff --git a/products/workflows/frontend/setupGuide/setupGuideSteps.ts b/products/workflows/frontend/setupGuide/setupGuideSteps.ts
index 1df651c85faf..3b6c8d355e49 100644
--- a/products/workflows/frontend/setupGuide/setupGuideSteps.ts
+++ b/products/workflows/frontend/setupGuide/setupGuideSteps.ts
@@ -1,3 +1,5 @@
+import type { ReachChannel } from './wizard/onboardingWizardSteps'
+
// pinned: analytics property values for the setup guide events - renaming breaks dashboards
export const SETUP_GUIDE_STEP_KEYS = ['channel', 'domain', 'opt-outs', 'email-template', 'first-journey'] as const
export type SetupGuideStepKey = (typeof SETUP_GUIDE_STEP_KEYS)[number]
@@ -10,19 +12,43 @@ export interface SetupGuideStep {
/** What the guide reads to decide which steps are done. `null` means the value has not loaded yet. */
export interface SetupGuideInputs {
emailChannels: { verified: boolean }[] | null
+ pushChannelCount: number | null
+ reachChannels: readonly ReachChannel[] | null
optOutCategoryCount: number | null
emailTemplateCount: number | null
hasMessagingWorkflow: boolean | null
}
+function emailInScope(
+ emailChannelCount: number,
+ pushChannelCount: number,
+ reachChannels: readonly ReachChannel[] | null
+): boolean {
+ if (emailChannelCount > 0) {
+ return true
+ }
+ if (reachChannels) {
+ return reachChannels.includes('email')
+ }
+ return pushChannelCount === 0
+}
+
/**
* The messaging setup steps, in order. Returns `null` until every input has loaded, so the guide never
* shows a step as open only because its data is still on the way.
*/
export function deriveSetupGuideSteps(inputs: SetupGuideInputs): SetupGuideStep[] | null {
- const { emailChannels, optOutCategoryCount, emailTemplateCount, hasMessagingWorkflow } = inputs
+ const {
+ emailChannels,
+ pushChannelCount,
+ reachChannels,
+ optOutCategoryCount,
+ emailTemplateCount,
+ hasMessagingWorkflow,
+ } = inputs
if (
emailChannels === null ||
+ pushChannelCount === null ||
optOutCategoryCount === null ||
emailTemplateCount === null ||
hasMessagingWorkflow === null
@@ -30,17 +56,23 @@ export function deriveSetupGuideSteps(inputs: SetupGuideInputs): SetupGuideStep[
return null
}
const done: Record<SetupGuideStepKey, boolean> = {
- channel: emailChannels.length > 0,
+ channel: emailChannels.length > 0 || pushChannelCount > 0,
domain: emailChannels.some((channel) => channel.verified),
'opt-outs': optOutCategoryCount > 0,
'email-template': emailTemplateCount > 0,
'first-journey': hasMessagingWorkflow,
}
- return SETUP_GUIDE_STEP_KEYS.map((key) => ({ key, done: done[key] }))
+ const withEmail = emailInScope(emailChannels.length, pushChannelCount, reachChannels)
+ return SETUP_GUIDE_STEP_KEYS.filter((key) => withEmail || !EMAIL_ONLY_STEPS.includes(key)).map((key) => ({
+ key,
+ done: done[key],
+ }))
}
+const EMAIL_ONLY_STEPS: SetupGuideStepKey[] = ['domain', 'email-template']
+
export const SETUP_GUIDE_STEP_LABELS: Record<SetupGuideStepKey, string> = {
- channel: 'Connect an email channel',
+ channel: 'Connect a channel',
domain: 'Verify your sending domain',
'opt-outs': 'Add opt-out categories',
'email-template': 'Design your first email',
diff --git a/products/workflows/frontend/setupGuide/wizard/WizardChannelStep.tsx b/products/workflows/frontend/setupGuide/wizard/WizardChannelStep.tsx
index 59b20a30429c..5f2d947ad8a4 100644
--- a/products/workflows/frontend/setupGuide/wizard/WizardChannelStep.tsx
+++ b/products/workflows/frontend/setupGuide/wizard/WizardChannelStep.tsx
@@ -39,7 +39,7 @@ export function WizardChannelStep(): JSX.Element {
<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
+ You need a domain you control, such as mail.example.com. You can add more channels later in
Messaging.
</p>
<LemonButton
diff --git a/products/workflows/frontend/setupGuide/wizard/WizardPushStep.tsx b/products/workflows/frontend/setupGuide/wizard/WizardPushStep.tsx
index e598a3aefaf7..987126325d96 100644
--- a/products/workflows/frontend/setupGuide/wizard/WizardPushStep.tsx
+++ b/products/workflows/frontend/setupGuide/wizard/WizardPushStep.tsx
@@ -1,8 +1,6 @@
import { useActions, useValues } from 'kea'
-import posthog from 'posthog-js'
-import { IconBell } from '@posthog/icons'
-import { LemonButton, Link } from '@posthog/lemon-ui'
+import { Link } from '@posthog/lemon-ui'
import { SetupTaskId } from 'lib/components/ProductSetup'
import { integrationsLogic } from 'lib/integrations/integrationsLogic'
@@ -10,7 +8,6 @@ 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' },
@@ -22,47 +19,6 @@ const SDK_REQUIREMENTS = [
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 (
<>
diff --git a/products/workflows/frontend/setupGuide/wizard/WizardReachStep.tsx b/products/workflows/frontend/setupGuide/wizard/WizardReachStep.tsx
new file mode 100644
index 000000000000..ca355c5caca6
--- /dev/null
+++ b/products/workflows/frontend/setupGuide/wizard/WizardReachStep.tsx
@@ -0,0 +1,68 @@
+import { useActions, useValues } from 'kea'
+
+import { IconLetter, IconPhone } from '@posthog/icons'
+import { LemonCheckbox } from '@posthog/lemon-ui'
+
+import { workflowsSetupGuideLogic } from '../workflowsSetupGuideLogic'
+import { REACH_CHANNELS, ReachChannel } from './onboardingWizardSteps'
+import { workflowsOnboardingWizardLogic } from './workflowsOnboardingWizardLogic'
+
+const REACH_OPTIONS: Record<ReachChannel, { icon: JSX.Element; title: string; description: string; needs: string }> = {
+ email: {
+ icon: <IconLetter />,
+ title: 'Email',
+ description: 'Onboarding, lifecycle and transactional email from your own domain.',
+ needs: 'You need access to the DNS settings of a domain you own.',
+ },
+ push: {
+ icon: <IconPhone />,
+ title: 'Push notifications',
+ description: 'Notifications on the phones of people who use your iOS or Android app.',
+ needs: 'You need Firebase or Apple push credentials and the PostHog SDK in your app.',
+ },
+}
+
+export function WizardReachStep(): JSX.Element {
+ const { reachChannels } = useValues(workflowsOnboardingWizardLogic)
+ const { setReachChannels } = useActions(workflowsSetupGuideLogic)
+ const selected = reachChannels ?? []
+
+ const toggle = (channel: ReachChannel, checked: boolean): void => {
+ setReachChannels(REACH_CHANNELS.filter((option) => (option === channel ? checked : selected.includes(option))))
+ }
+
+ return (
+ <div className="@container flex flex-col gap-3">
+ <div className="grid grid-cols-1 gap-3 @2xl:grid-cols-2">
+ {REACH_CHANNELS.map((channel) => {
+ const option = REACH_OPTIONS[channel]
+ return (
+ <LemonCheckbox
+ key={channel}
+ bordered
+ fullWidth
+ className="h-full"
+ labelClassName="h-full items-start py-2"
+ checked={selected.includes(channel)}
+ onChange={(checked) => toggle(channel, checked)}
+ data-attr={`workflows-onboarding-wizard-reach-${channel}`}
+ label={
+ <span className="flex flex-col gap-1">
+ <span className="flex items-center gap-2 font-semibold">
+ <span className="text-lg flex">{option.icon}</span>
+ {option.title}
+ </span>
+ <span className="text-secondary font-normal">{option.description}</span>
+ <span className="text-tertiary text-xs font-normal">{option.needs}</span>
+ </span>
+ }
+ />
+ )
+ })}
+ </div>
+ <p className="mb-0 text-secondary text-sm">
+ SMS and Slack are in Messaging once setup is done. You can add any channel later.
+ </p>
+ </div>
+ )
+}
diff --git a/products/workflows/frontend/setupGuide/wizard/WorkflowsOnboardingWizard.tsx b/products/workflows/frontend/setupGuide/wizard/WorkflowsOnboardingWizard.tsx
index 9e4e2e423b22..9c73d2d803dd 100644
--- a/products/workflows/frontend/setupGuide/wizard/WorkflowsOnboardingWizard.tsx
+++ b/products/workflows/frontend/setupGuide/wizard/WorkflowsOnboardingWizard.tsx
@@ -19,6 +19,7 @@ import { WizardConnectStep } from './WizardConnectStep'
import { WizardCreateStep } from './WizardCreateStep'
import { WizardDomainStep } from './WizardDomainStep'
import { WizardPushStep } from './WizardPushStep'
+import { WizardReachStep } from './WizardReachStep'
import { WizardSendingRulesStep } from './WizardSendingRulesStep'
import { WizardTemplateStep } from './WizardTemplateStep'
import { workflowsOnboardingWizardLogic } from './workflowsOnboardingWizardLogic'
@@ -121,6 +122,7 @@ export function WorkflowsOnboardingWizard(): JSX.Element {
)}
</div>
<LemonCard hoverEffect={false} className="p-6">
+ {currentStep === 'reach' && <WizardReachStep />}
{currentStep === 'channel' && <WizardChannelStep />}
{currentStep === 'domain' && <WizardDomainStep />}
{currentStep === 'opt-outs' && (
diff --git a/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.test.ts b/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.test.ts
index 3ae3247ed2c6..2e1561892551 100644
--- a/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.test.ts
+++ b/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.test.ts
@@ -6,6 +6,7 @@ import {
requiredConnections,
sendingRulesToSave,
wizardSteps,
+ ReachChannel,
} from './onboardingWizardSteps'
describe('onboardingWizardSteps', () => {
@@ -33,28 +34,45 @@ describe('onboardingWizardSteps', () => {
expect(firstOpenStepIndex(MESSAGING_WIZARD_STEPS, done)).toBe(expected)
})
- test.each<[string, 'messaging' | 'automation' | 'broadcast', boolean, string[]]>([
+ test.each<[string, 'messaging' | 'automation' | 'broadcast', boolean, ReachChannel[] | null, string[]]>([
[
- 'messaging asks about push before the journey',
+ 'messaging asks which channels before any channel setup',
'messaging',
true,
- ['channel', 'domain', 'opt-outs', 'sending-rules', 'push', 'journey'],
+ null,
+ ['reach', 'opt-outs', 'sending-rules', 'journey'],
+ ],
+ [
+ 'push only skips the email steps',
+ 'messaging',
+ true,
+ ['push'],
+ ['reach', 'push', 'opt-outs', 'sending-rules', 'journey'],
+ ],
+ [
+ 'email and push set up email first',
+ 'messaging',
+ true,
+ ['email', 'push'],
+ ['reach', 'channel', 'domain', 'push', 'opt-outs', 'sending-rules', 'journey'],
],
[
'messaging without push keeps the email steps',
'messaging',
false,
+ ['push'],
['channel', 'domain', 'opt-outs', 'sending-rules', 'journey'],
],
- ['automation never asks about push', 'automation', true, ['template', 'connect', 'create']],
+ ['automation never asks about push', 'automation', true, ['push'], ['template', 'connect', 'create']],
[
'broadcasts send email only, so they never ask about push',
'broadcast',
true,
+ ['push'],
['channel', 'domain', 'opt-outs', 'sending-rules', 'broadcast'],
],
- ])('%s', (_, path, pushEnabled, expected) => {
- expect(wizardSteps(path, pushEnabled)).toEqual(expected)
+ ])('%s', (_, path, pushEnabled, reachChannels, expected) => {
+ expect(wizardSteps(path, pushEnabled, reachChannels)).toEqual(expected)
})
const unset = { maxMessages: null, windowDays: null }
diff --git a/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.ts b/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.ts
index 3cba14e91c9c..c55ae995aeb0 100644
--- a/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.ts
+++ b/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.ts
@@ -17,11 +17,19 @@ export const MESSAGING_WIZARD_STEPS = ['channel', 'domain', 'opt-outs', 'sending
export const AUTOMATION_WIZARD_STEPS = ['template', 'connect', 'create'] as const
export const BROADCAST_WIZARD_STEPS = ['channel', 'domain', 'opt-outs', 'sending-rules', 'broadcast'] as const
export const PUSH_WIZARD_STEP = 'push' as const
+export const REACH_WIZARD_STEP = 'reach' as const
export type WizardStepKey =
| (typeof MESSAGING_WIZARD_STEPS)[number]
| (typeof AUTOMATION_WIZARD_STEPS)[number]
| (typeof BROADCAST_WIZARD_STEPS)[number]
| typeof PUSH_WIZARD_STEP
+ | typeof REACH_WIZARD_STEP
+
+// pinned: URL values and analytics property values of the reach step - renaming breaks links and dashboards
+export const REACH_CHANNELS = ['email', 'push'] as const
+export type ReachChannel = (typeof REACH_CHANNELS)[number]
+
+const EMAIL_WIZARD_STEPS: readonly WizardStepKey[] = ['channel', 'domain']
// pinned: URL path and search params of the wizard - renaming breaks the Slack sign-in return link
export const ONBOARDING_WIZARD_TAB = 'onboarding'
@@ -53,15 +61,23 @@ export const WIZARD_STEPS: Record<WorkflowsOnboardingPath, readonly WizardStepKe
broadcast: BROADCAST_WIZARD_STEPS,
}
-/** The steps of one path. Messaging asks about push before the first journey when the project can send push.
- * Broadcasts only send email, so that path never asks. */
-export function wizardSteps(path: WorkflowsOnboardingPath, pushEnabled: boolean): readonly WizardStepKey[] {
+/** Broadcasts only send email, so that path never asks which channels to set up. */
+export function wizardSteps(
+ path: WorkflowsOnboardingPath,
+ pushEnabled: boolean,
+ reachChannels: readonly ReachChannel[] | null = null
+): 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)]
+ const shared = steps.filter((step) => !EMAIL_WIZARD_STEPS.includes(step))
+ return [
+ REACH_WIZARD_STEP,
+ ...(reachChannels?.includes('email') ? EMAIL_WIZARD_STEPS : []),
+ ...(reachChannels?.includes('push') ? [PUSH_WIZARD_STEP] : []),
+ ...shared,
+ ]
}
export interface WizardStepCopy {
@@ -73,8 +89,14 @@ export interface WizardStepCopy {
}
export const WIZARD_STEP_COPY: Record<WizardStepKey, WizardStepCopy> = {
+ reach: {
+ label: 'Channels',
+ title: 'How do you want to reach people?',
+ description: 'Pick every channel you want to send from. Setup only asks about the ones you pick.',
+ optional: false,
+ },
channel: {
- label: 'Email channel',
+ label: 'Email',
title: 'Connect the email address you send from',
description: 'Email goes out from your own domain. Add the address that people see in their inbox.',
optional: false,
@@ -97,21 +119,21 @@ export const WIZARD_STEP_COPY: Record<WizardStepKey, WizardStepCopy> = {
label: 'Sending rules',
title: 'Choose how often people hear from you',
description:
- 'These rules apply to every workflow and broadcast in this project. The defaults keep people from getting too many marketing emails. You can change them later in Messaging settings.',
+ 'These rules apply to every workflow and broadcast in this project. The defaults keep people from getting too many marketing messages. You can change them later in Messaging settings.',
optional: false,
},
push: {
label: 'Push',
- title: 'Send push notifications too?',
+ title: 'Set up push notifications',
description:
- 'Reach people on their phones as well as in their inbox. You can also set this up later in Messaging.',
- optional: true,
+ 'Connect the service that delivers to your app, then turn on push in the PostHog SDK. Devices register themselves when your app starts.',
+ optional: false,
},
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.',
+ 'Start from a template or from scratch. It opens in the editor, where you change the trigger and the messages and save it as a draft. Nothing sends until you launch it.',
optional: false,
},
broadcast: {
diff --git a/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.ts b/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.ts
index 09b48e850579..7e63da79620d 100644
--- a/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.ts
+++ b/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.ts
@@ -12,6 +12,8 @@ import { urls } from 'scenes/urls'
import type { IntegrationType, TeamPublicType, TeamType } from '~/types'
import { newBroadcastAgentLogic } from '../../Broadcasts/newBroadcastAgentLogic'
+import { PUSH_CHANNELS } from '../../Channels/channelSummary'
+import type { ChannelType } from '../../Channels/MessageChannels'
import type { HogFlowTemplate } from '../../Workflows/hogflows/types'
import { newWorkflowLogic } from '../../Workflows/newWorkflowLogic'
import { workflowTemplatesLogic } from '../../Workflows/templates/workflowTemplatesLogic'
@@ -25,6 +27,8 @@ import {
FrequencyCapChoice,
RECOMMENDED_FREQUENCY_CAP,
ONBOARDING_WIZARD_TAB,
+ REACH_CHANNELS,
+ ReachChannel,
WIZARD_ENTRIES,
WIZARD_STEP_COPY,
WizardConnection,
@@ -55,6 +59,7 @@ export interface workflowsOnboardingWizardLogicValues {
currentTeamLoading: boolean // teamLogic
workflowTemplates: HogFlowTemplate[] // workflowTemplatesLogic
workflowTemplatesLoading: boolean // workflowTemplatesLogic
+ chosenReachChannels: ReachChannel[] | null // workflowsSetupGuideLogic
guideSteps: SetupGuideStep[] | null // workflowsSetupGuideLogic
canEditSendingRules: boolean
chosenFrequencyCap: FrequencyCap
@@ -72,7 +77,7 @@ export interface workflowsOnboardingWizardLogicValues {
missingConnections: WizardConnection[]
offersSuggestions: boolean
pushEnabled: boolean
- pushSetupStarted: boolean
+ reachChannels: ReachChannel[] | null
savedFrequencyCap: FrequencyCap
selectedTemplate: HogFlowTemplate | null
selectedTemplateId: string | null
@@ -92,6 +97,20 @@ export interface workflowsOnboardingWizardLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface workflowsOnboardingWizardLogicActions {
+ loadIntegrationsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ } // integrationsLogic
+ loadIntegrationsSuccess: (
+ integrations: IntegrationType[],
+ payload?: any
+ ) => {
+ integrations: IntegrationType[]
+ payload?: any
+ } // integrationsLogic
startNewBroadcast: () => {
value: true
} // newBroadcastAgentLogic
@@ -117,6 +136,9 @@ export interface workflowsOnboardingWizardLogicActions {
hasMessagingWorkflow: boolean
payload?: any
} // workflowsSetupGuideLogic
+ setReachChannels: (reachChannels: ('email' | 'push')[]) => {
+ reachChannels: ('email' | 'push')[]
+ } // workflowsSetupGuideLogic
back: () => {
value: true
}
@@ -151,6 +173,9 @@ export interface workflowsOnboardingWizardLogicActions {
next: () => {
value: true
}
+ openFromUrl: (searchParams: Record<string, any>) => {
+ searchParams: Record<string, any>
+ }
positionAtFirstOpenStep: (index: number) => {
index: number
}
@@ -175,9 +200,6 @@ export interface workflowsOnboardingWizardLogicActions {
setTemplatesShown: (shown: boolean) => {
shown: boolean
}
- startPushSetup: () => {
- value: true
- }
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -209,7 +231,15 @@ export interface workflowsOnboardingWizardLogicMeta {
canEditSendingRules: boolean
) => boolean
canEditSendingRules: (currentTeam: TeamPublicType | TeamType | null) => boolean
- stepKeys: (wizardPath: WorkflowsOnboardingPath, pushEnabled: boolean) => readonly WizardStepKey[]
+ reachChannels: (
+ chosenReachChannels: ('email' | 'push')[] | null,
+ integrations: IntegrationType[] | null
+ ) => ReachChannel[] | null
+ stepKeys: (
+ wizardPath: WorkflowsOnboardingPath,
+ pushEnabled: boolean,
+ reachChannels: ('email' | 'push')[] | null
+ ) => readonly WizardStepKey[]
currentStep: (stepKeys: readonly WizardStepKey[], stepIndex: number) => WizardStepKey
offersSuggestions: (wizardPath: WorkflowsOnboardingPath) => boolean
suggestionsFirst: (offersSuggestions: boolean, currentStep: WizardStepKey, templatesShown: boolean) => boolean
@@ -230,7 +260,8 @@ export interface workflowsOnboardingWizardLogicMeta {
integrations: IntegrationType[] | null,
startsBlank: boolean,
setupCheckFailed: boolean,
- savedFrequencyCap: FrequencyCap
+ savedFrequencyCap: FrequencyCap,
+ reachChannels: ('email' | 'push')[] | null
) => Partial<Record<WizardStepKey, boolean>> | null
continueDisabledReason: (
currentStep: WizardStepKey,
@@ -250,12 +281,18 @@ export type workflowsOnboardingWizardLogicType = MakeLogicType<
workflowsOnboardingWizardLogicMeta
>
+const BLOCKED_STEP_REASONS: Partial<Record<WizardStepKey, string>> = {
+ reach: 'Pick at least one channel',
+ channel: 'Connect an email channel first',
+ push: 'Connect Firebase or Apple Push Notifications first',
+}
+
export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogicType>([
path(['products', 'workflows', 'frontend', 'setupGuide', 'wizard', 'workflowsOnboardingWizardLogic']),
connect(() => ({
values: [
workflowsSetupGuideLogic,
- ['steps as guideSteps'],
+ ['steps as guideSteps', 'chosenReachChannels'],
integrationsLogic,
['integrations'],
featureFlagLogic,
@@ -271,9 +308,16 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
newBroadcastAgentLogic,
['startNewBroadcast'],
workflowsSetupGuideLogic,
- ['loadHasMessagingWorkflow', 'loadHasMessagingWorkflowFailure', 'loadHasMessagingWorkflowSuccess'],
+ [
+ 'loadHasMessagingWorkflow',
+ 'loadHasMessagingWorkflowFailure',
+ 'loadHasMessagingWorkflowSuccess',
+ 'setReachChannels',
+ ],
teamLogic,
['updateCurrentTeam'],
+ integrationsLogic,
+ ['loadIntegrationsSuccess', 'loadIntegrationsFailure'],
],
})),
actions({
@@ -290,6 +334,7 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
templateId,
entry,
}),
+ openFromUrl: (searchParams: Record<string, any>) => ({ searchParams }),
setStepIndex: (index: number) => ({ index }),
next: true,
back: true,
@@ -298,7 +343,6 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
exit: true,
positionAtFirstOpenStep: (index: number) => ({ index }),
positionIfReady: true,
- startPushSetup: true,
setEngagementEventsChoice: (enabled: boolean) => ({ enabled }),
setFrequencyCapChoice: (choice: FrequencyCapChoice) => ({ choice }),
setCustomFrequencyCap: (cap: FrequencyCap) => ({ cap }),
@@ -378,12 +422,6 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
setEngagementEventsChoice: (_, { enabled }) => enabled,
},
],
- pushSetupStarted: [
- false,
- {
- startPushSetup: () => true,
- },
- ],
setupCheckFailed: [
false,
{
@@ -455,10 +493,32 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
(currentTeam: TeamType | null): boolean =>
(currentTeam?.effective_membership_level ?? -1) >= TeamMembershipLevel.Admin,
],
+ reachChannels: [
+ (s) => [s.chosenReachChannels, s.integrations],
+ (
+ chosenReachChannels: ReachChannel[] | null,
+ integrations: IntegrationType[] | null
+ ): ReachChannel[] | null => {
+ if (chosenReachChannels) {
+ return chosenReachChannels
+ }
+ const connected = REACH_CHANNELS.filter((channel) =>
+ integrations?.some((integration) =>
+ channel === 'email'
+ ? integration.kind === 'email'
+ : PUSH_CHANNELS.includes(integration.kind as ChannelType)
+ )
+ )
+ return connected.length ? connected : null
+ },
+ ],
stepKeys: [
- (s) => [s.wizardPath, s.pushEnabled],
- (wizardPath: WorkflowsOnboardingPath, pushEnabled: boolean): readonly WizardStepKey[] =>
- wizardSteps(wizardPath, pushEnabled),
+ (s) => [s.wizardPath, s.pushEnabled, s.reachChannels],
+ (
+ wizardPath: WorkflowsOnboardingPath,
+ pushEnabled: boolean,
+ reachChannels: ReachChannel[] | null
+ ): readonly WizardStepKey[] => wizardSteps(wizardPath, pushEnabled, reachChannels),
],
currentStep: [
(s) => [s.stepKeys, s.stepIndex],
@@ -518,6 +578,7 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
s.startsBlank,
s.setupCheckFailed,
s.savedFrequencyCap,
+ s.reachChannels,
],
(
wizardPath: WorkflowsOnboardingPath,
@@ -527,7 +588,8 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
integrations: IntegrationType[] | null,
startsBlank: boolean,
setupCheckFailed: boolean,
- savedFrequencyCap: FrequencyCap
+ savedFrequencyCap: FrequencyCap,
+ reachChannels: ReachChannel[] | null
): Partial<Record<WizardStepKey, boolean>> | null => {
const picked = !!selectedTemplate || startsBlank
if (wizardPath === 'automation') {
@@ -540,12 +602,13 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
}
const guideDone = (key: string): boolean => !!guideSteps?.some((step) => step.key === key && step.done)
return {
+ reach: !!reachChannels?.length,
channel: !!integrations?.some((integration) => integration.kind === 'email'),
domain: guideDone('domain'),
'opt-outs': guideDone('opt-outs'),
'sending-rules': savedFrequencyCap.maxMessages !== null && savedFrequencyCap.windowDays !== null,
- push: !!integrations?.some(
- (integration) => integration.kind === 'firebase' || integration.kind === 'apns'
+ push: !!integrations?.some((integration) =>
+ PUSH_CHANNELS.includes(integration.kind as ChannelType)
),
journey: picked,
broadcast: false,
@@ -588,11 +651,11 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
if (!stepDone) {
return 'Checking your setup'
}
- return stepDone[currentStep] ? null : 'Connect an email channel first'
+ return stepDone[currentStep] ? null : (BLOCKED_STEP_REASONS[currentStep] ?? 'Finish this step first')
},
],
}),
- listeners(({ actions, values }) => {
+ listeners(({ actions, values, cache }) => {
// Sent once the wizard settles on a step, so a person who opens it fresh does not count a view of
// the first step before it moves to their first open one.
const captureStepViewed = (): void => {
@@ -605,6 +668,49 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
})
}
return {
+ openFromUrl: ({ searchParams }) => {
+ const path = searchParams.path
+ if (!isOnboardingPath(path)) {
+ return
+ }
+ // The messaging steps depend on the connected channels, so a step read before they load
+ // would land on the wrong step, or on none.
+ if (path === 'messaging' && values.integrations === null && values.chosenReachChannels === null) {
+ cache.pendingSearchParams = searchParams
+ return
+ }
+ cache.pendingSearchParams = null
+ const steps = wizardSteps(path, values.pushEnabled, values.reachChannels)
+ const step = steps.includes(searchParams.step) ? (searchParams.step as WizardStepKey) : null
+ const templateId = searchParams.template ? String(searchParams.template) : null
+ const entry = isWizardEntry(searchParams.entry) ? searchParams.entry : null
+ if (
+ !values.initialized ||
+ path !== values.wizardPath ||
+ step !== values.currentStep ||
+ templateId !== values.selectedTemplateId
+ ) {
+ actions.initWizard(path, step, step ? steps.indexOf(step) : 0, templateId, entry)
+ }
+ },
+ loadIntegrationsSuccess: () => {
+ if (cache.pendingSearchParams) {
+ actions.openFromUrl(cache.pendingSearchParams)
+ }
+ },
+ loadIntegrationsFailure: () => {
+ if (cache.pendingSearchParams) {
+ const searchParams = cache.pendingSearchParams
+ cache.pendingSearchParams = null
+ actions.initWizard(
+ searchParams.path,
+ null,
+ 0,
+ searchParams.template ? String(searchParams.template) : null,
+ isWizardEntry(searchParams.entry) ? searchParams.entry : null
+ )
+ }
+ },
setStepIndex: captureStepViewed,
positionAtFirstOpenStep: captureStepViewed,
next: () => {
@@ -723,24 +829,9 @@ export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogic
actions.positionIfReady()
},
})),
- urlToAction(({ actions, values }) => ({
+ urlToAction(({ actions }) => ({
[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
- const entry = isWizardEntry(searchParams.entry) ? searchParams.entry : null
- if (
- !values.initialized ||
- path !== values.wizardPath ||
- step !== values.currentStep ||
- templateId !== values.selectedTemplateId
- ) {
- actions.initWizard(path, step, step ? steps.indexOf(step) : 0, templateId, entry)
- }
+ actions.openFromUrl(searchParams)
},
})),
// Keeps the step and the picked template in the URL, so a person who leaves to sign in to Slack
diff --git a/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.ts b/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.ts
index ce490206e701..01ab997913a2 100644
--- a/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.ts
+++ b/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.ts
@@ -11,6 +11,8 @@ import { urls } from 'scenes/urls'
import type { IntegrationType } from '../../../../frontend/src/types'
import { newBroadcastAgentLogic } from '../Broadcasts/newBroadcastAgentLogic'
+import { PUSH_CHANNELS } from '../Channels/channelSummary'
+import type { ChannelType } from '../Channels/MessageChannels'
import { hogFlowsList } from '../generated/api'
import { optOutCategoriesLogic } from '../OptOuts/optOutCategoriesLogic'
import type { MessageCategory } from '../OptOuts/optOutCategoriesLogic'
@@ -19,7 +21,7 @@ import type { MessageTemplate } from '../TemplateLibrary/types'
import { workflowTemplatesLogic } from '../Workflows/templates/workflowTemplatesLogic'
import type { WorkflowTemplateTypeFilter } from '../Workflows/workflowTypeFilters'
import { SetupGuideStep, SetupGuideStepKey, deriveSetupGuideSteps } from './setupGuideSteps'
-import { onboardingWizardUrl } from './wizard/onboardingWizardSteps'
+import { ReachChannel, onboardingWizardUrl } from './wizard/onboardingWizardSteps'
// pinned: analytics property values for `workflows onboarding path selected` - renaming breaks dashboards
export type WorkflowsOnboardingPath = 'messaging' | 'automation' | 'broadcast'
@@ -28,9 +30,15 @@ export interface TeamSetupGuideState {
path: WorkflowsOnboardingPath | null
guideHidden: boolean
automationSuggestionDismissed: boolean
+ reachChannels?: ReachChannel[] | null
}
-const EMPTY_TEAM_STATE: TeamSetupGuideState = { path: null, guideHidden: false, automationSuggestionDismissed: false }
+const EMPTY_TEAM_STATE: TeamSetupGuideState = {
+ path: null,
+ guideHidden: false,
+ automationSuggestionDismissed: false,
+ reachChannels: null,
+}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface workflowsSetupGuideLogicValues {
@@ -42,6 +50,7 @@ export interface workflowsSetupGuideLogicValues {
currentProjectId: number | null // projectLogic
currentTeamId: number | null // teamLogic
chosenPath: WorkflowsOnboardingPath | null
+ chosenReachChannels: ReachChannel[] | null
completedCount: number
hasMessagingWorkflow: boolean | null
hasMessagingWorkflowLoading: boolean
@@ -90,6 +99,9 @@ export interface workflowsSetupGuideLogicActions {
hasMessagingWorkflow: boolean
payload?: any
}
+ setReachChannels: (reachChannels: ReachChannel[]) => {
+ reachChannels: ('email' | 'push')[]
+ }
stepClicked: (step: SetupGuideStepKey) => {
step: 'channel' | 'domain' | 'email-template' | 'first-journey' | 'opt-outs'
}
@@ -110,8 +122,10 @@ export interface workflowsSetupGuideLogicMeta {
currentTeamId: number | null
) => TeamSetupGuideState
chosenPath: (teamState: TeamSetupGuideState) => WorkflowsOnboardingPath | null
+ chosenReachChannels: (teamState: TeamSetupGuideState) => ReachChannel[] | null
steps: (
integrations: IntegrationType[] | null,
+ chosenReachChannels: ('email' | 'push')[] | null,
categories: import('products/messaging/frontend/generated/api.schemas').MessageCategoryApi[],
categoriesLoading: boolean,
templates: MessageTemplate[],
@@ -154,6 +168,7 @@ export const workflowsSetupGuideLogic = kea<workflowsSetupGuideLogicType>([
actions({
choosePath: (path: WorkflowsOnboardingPath) => ({ path }),
hideGuide: true,
+ setReachChannels: (reachChannels: ReachChannel[]) => ({ reachChannels }),
dismissAutomationSuggestion: true,
stepClicked: (step: SetupGuideStepKey) => ({ step }),
browseTemplates: (typeFilter: WorkflowTemplateTypeFilter) => ({ typeFilter }),
@@ -193,9 +208,14 @@ export const workflowsSetupGuideLogic = kea<workflowsSetupGuideLogicType>([
(currentTeamId !== null && stateByTeam[String(currentTeamId)]) || EMPTY_TEAM_STATE,
],
chosenPath: [(s) => [s.teamState], (teamState: TeamSetupGuideState) => teamState.path],
+ chosenReachChannels: [
+ (s) => [s.teamState],
+ (teamState: TeamSetupGuideState): ReachChannel[] | null => teamState.reachChannels ?? null,
+ ],
steps: [
(s) => [
s.integrations,
+ s.chosenReachChannels,
s.categories,
s.categoriesLoading,
s.templates,
@@ -204,6 +224,7 @@ export const workflowsSetupGuideLogic = kea<workflowsSetupGuideLogicType>([
],
(
integrations: IntegrationType[] | null,
+ chosenReachChannels: ReachChannel[] | null,
categories: import('products/messaging/frontend/generated/api.schemas').MessageCategoryApi[],
categoriesLoading: boolean,
templates: MessageTemplate[],
@@ -217,6 +238,13 @@ export const workflowsSetupGuideLogic = kea<workflowsSetupGuideLogicType>([
: integrations
.filter((integration) => integration.kind === 'email')
.map((integration) => ({ verified: integration.config?.verified === true })),
+ pushChannelCount:
+ integrations === null
+ ? null
+ : integrations.filter((integration) =>
+ PUSH_CHANNELS.includes(integration.kind as ChannelType)
+ ).length,
+ reachChannels: chosenReachChannels,
// The loaders start from an empty list, so "loading" is the only way to tell "not loaded yet".
optOutCategoryCount: categoriesLoading && categories.length === 0 ? null : categories.length,
emailTemplateCount: templatesLoading && templates.length === 0 ? null : templates.length,
@@ -283,6 +311,13 @@ export const workflowsSetupGuideLogic = kea<workflowsSetupGuideLogicType>([
// pinned: analytics event name - renaming breaks dashboards
posthog.capture('workflows setup guide hidden', { completed_steps: values.completedCount })
},
+ setReachChannels: ({ reachChannels }) => {
+ if (values.currentTeamId !== null) {
+ actions.updateTeamState(String(values.currentTeamId), { reachChannels })
+ }
+ // pinned: analytics event name - renaming breaks dashboards
+ posthog.capture('workflows onboarding reach channels selected', { channels: reachChannels })
+ },
dismissAutomationSuggestion: () => {
if (values.currentTeamId !== null) {
actions.updateTeamState(String(values.currentTeamId), { automationSuggestionDismissed: true })