: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 the email sending domain wizard page (#120423)
Meikel Ratz4676578b306a
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 60803494a71c..fe86a02ce4ed 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -15936,6 +15936,70 @@ snapshots:hash: v1.k794b7964.074d7d64c384134bfd4c223d57cd339854d39bc4283b7d9b239d4c83d78e30fb._jPmYLjyiEistYmpwqii497iwY6LHQ1WQ4nzk9aMTDsscenes-app-workflows-createaitaskconnectors--unavailable-connector--light:hash: v1.k794b7964.c4fdab3ab5190ace67d354d7010b49cbd37e9ec72feaa3fab9760d1f1010c8b0.S5qBDGrQNUo7qygcV1_MG_nu9RWeaMnoOFrYdhnV97E+ scenes-app-workflows-email-domain-setup--agent-handoff--dark:+ hash: v1.k794b7964.dfe5f861abff7bb343c4150e6b4dc8444e8f373596f6bd328418f52216446904.hKcuU-QswaiocgajSPR3WLjuw0XaDOoQz4HR85H4Yvs+ scenes-app-workflows-email-domain-setup--agent-handoff--light:+ hash: v1.k794b7964.90dc0c6b93cd7e2107bb89ef97667917b1594e96b60316bb5f190721fb4134fa.PYOR4mt8Py_Hp3RSx9c0vdFhgRO17pX7oDw3DnOW09k+ scenes-app-workflows-email-domain-setup--domain-step--dark:+ hash: v1.k794b7964.6d4f99c567d1b980a89647ad047f2f1993274984c0962f4d8c00f9739bb97c5b.ExejW479E1j1jZ75H4rj5bCgM9HumucYJKU74zcLb2Y+ scenes-app-workflows-email-domain-setup--domain-step--light:+ hash: v1.k794b7964.7e18430997c1e715034e832316d53a49f739cb65b502a993b67d27251f48ab0c.hDMDffZBhSfaVOGABAWtiAid9Oc8BrkvaOWsAQQm8Vc+ scenes-app-workflows-email-domain-setup--ready--dark:+ hash: v1.k794b7964.b8c9bf82888036b0531195d03a3cde74707c7fa3ffa34ea846e09390bb6e67a9.n0n9apB1NCh7klnrDcyDkEqRT-rhkr-td3gKPdTiW0A+ scenes-app-workflows-email-domain-setup--ready--light:+ hash: v1.k794b7964.af9862fdbe9465830d4c11c2586315bf01ed9b55aba52caa78c485697d33bcfc.U9NNvRqsz7F2nkHkoabxQwQU5aeEbJLNaUBG-VRyvJc+ scenes-app-workflows-email-domain-setup--settings-cloudflare--dark:+ hash: v1.k794b7964.9e3bd23d6d107f8cc6a8d5d482152945ee45e9d8fa63c4b8bf2bfdf7c2719ca7.ZrO_h6pJgHU1ZMi0TXHqxCPePvgZItDlz3NNd1L3XUo+ scenes-app-workflows-email-domain-setup--settings-cloudflare--light:+ hash: v1.k794b7964.a6fda0d5595b5e577b4535a535131fc44f6af4ee37451c6871f9556400afcb7e.zsoQpM80da4JdAEHn7NnseTk4FLD4H4-cbYYfj28nNI+ scenes-app-workflows-email-domain-setup--settings-cloudflare-existing-dmarc--dark:+ hash: v1.k794b7964.9e3bd23d6d107f8cc6a8d5d482152945ee45e9d8fa63c4b8bf2bfdf7c2719ca7.ICB-ce_JA0RMD29kskswwnvIw51A2Ze1GX9bSdizaNU+ scenes-app-workflows-email-domain-setup--settings-cloudflare-existing-dmarc--light:+ hash: v1.k794b7964.a6fda0d5595b5e577b4535a535131fc44f6af4ee37451c6871f9556400afcb7e.ELsQZ_rmsn4Z8rJ6dVw428T7yxDiZFt1kbLrbz5sQjg+ scenes-app-workflows-email-domain-setup--settings-cloudflare-records-revealed--dark:+ hash: v1.k794b7964.3074f4d5735adf13c4dd9af0f9491842d3424565b41d187bc9305fa87b2dd57a.zOX6kLLBUNdmv21-1F93GQL8TLZwm1J__GuEJjWT0vw+ scenes-app-workflows-email-domain-setup--settings-cloudflare-records-revealed--light:+ hash: v1.k794b7964.35d45f9f16597b3d634e3fbb2da18838ea735ef1da8ff26d8ed50f61edf5f9f3.jFSGBgP8zj1x6_woRD6DXuNznF1f7zn_7YRtUwv96o8+ scenes-app-workflows-email-domain-setup--settings-not-started--dark:+ hash: v1.k794b7964.5cf84de453e0c0610b2bec9981920d91ccd86a26433334cddf22a37b41b047df.tbiQTpvv0G_5zKUMIRpcnb5FcWncw_f6hJWMNxNHoww+ scenes-app-workflows-email-domain-setup--settings-not-started--light:+ hash: v1.k794b7964.fd9b1c0c69468c8a27c3a8d8dea9822cc975d6206ad38a417f8c53a470db7410.3AUJxQJuTvQnHGwVHlH_0KhrnzPnS-0q5ZWhgawZ91Y+ scenes-app-workflows-email-domain-setup--settings-route-53--dark:+ hash: v1.k794b7964.36ec94b68befcb3dd9747dc1030de0dc980fcbc639d4cb7dc6e46dd88006f892.LxN_Pzja2ZL9RoaZDaafX_N_3XrANetiCP1_o0-XV0Y+ scenes-app-workflows-email-domain-setup--settings-route-53--light:+ hash: v1.k794b7964.acdd3c07a3448384a06f1c4dd0b0ac430bce2326478cfc7c0f267e823744482a.IqX9hbIXAz6_-tsjFdmI5wiegLuDK_bQz2VEhtYsq8E+ scenes-app-workflows-email-domain-setup--settings-unknown-host--dark:+ hash: v1.k794b7964.c91e97346e23f52a309f39ce65104f274150ce045401d2e46777e04d9cbb6c9e.RuuPshdRl3gafxw2cJ2C4ydOv-W8oWbluMx1UIDmSXA+ scenes-app-workflows-email-domain-setup--settings-unknown-host--light:+ hash: v1.k794b7964.f4a231e5ebe27516f544e72f03cf15047053878efdfb6a10b8c9745a555a58bb.Mef01_MVyW2EgFuurnXVB0jERg_N5HzDSBDbQ2trDaU+ scenes-app-workflows-email-domain-setup--unavailable--dark:+ hash: v1.k794b7964.61c4c12372f025b48ec8255a7f5780ac99dfe6f7ffb36a65e699178ba2279e1d.QYx6BkJGZjZEec-YAGnU-EKjfTGxNR33U7ACrcv_RnQ+ scenes-app-workflows-email-domain-setup--unavailable--light:+ hash: v1.k794b7964.213417fb14b73e103079e041b77df50237a5260ac540c70526bdd752843b1b0e.ORXhzTNMwbaR_sjZvU_BeSXo_WEC0PW-p1C5GnUQOmQ+ scenes-app-workflows-email-domain-setup--verifying--dark:+ hash: v1.k794b7964.3f1ab1b274225399ec4b37cc55d31116b7b7f87b47a1246c30b071541d411879.oLKKTVDpaQN7FzCvcQTWtnwCljpsuDRnPKKliNsNaTE+ scenes-app-workflows-email-domain-setup--verifying--light:+ hash: v1.k794b7964.ae4908887653a9eae846e380650467b5b637244dfa5e12a6a4e359f7d341fb19.GgDiWzLfo4M4rI_iXdqVvVS58uH8Tsz4TaK33xrYQTY+ scenes-app-workflows-email-domain-setup--verifying-failed--dark:+ hash: v1.k794b7964.f3e9af482c0d7367beae6d05e58210139c816c96168114662dde536c41b16df3.jeHj03joz2aQjpDn3BfxqTJq1pa0yCAob9ZdWZDIjCs+ scenes-app-workflows-email-domain-setup--verifying-failed--light:+ hash: v1.k794b7964.2327706c66d45e61b834024e08956b42eef9c47a80b95371b368ea90ce6bc09f.fb_HlLG_KfPO2EqcKUWCDABs7scRZOMr2eAU2_SC8VM+ scenes-app-workflows-email-domain-setup--verifying-polling-stopped--dark:+ hash: v1.k794b7964.a7439edf2e9059927389d3546ade31d39f54eee0e0a91b6dcd94e3490e31230f.GkEy-r6uU79qm23sTADULOS4_m9zLcpgC-o9lrBlXtc+ scenes-app-workflows-email-domain-setup--verifying-polling-stopped--light:+ hash: v1.k794b7964.ce0c3409d020824b8bccc7c12bbca7ad3957b1954d57110691a62aefee00922d.QDH7ReMYLPxydlZI5P-5NEGBlmAy-C5advhjLbM3nWE+ scenes-app-workflows-email-domain-setup--verifying-records-found--dark:+ hash: v1.k794b7964.d7f2184e4eec06d342afd1971d00b79860d151e75b4b9279395170ac9f528c1b.qgELFbPSti7ERgtyVeuBGc0elI-2Y8rXhTA3MEz6LkY+ scenes-app-workflows-email-domain-setup--verifying-records-found--light:+ hash: v1.k794b7964.67824d30816917637d404365d42e4f89db5231bc4dfc4ceb9b636273bd25ab83.65RSumyUqseyy1wTtulfVXE-p74gbj0eLqfdrsNwnXo+ scenes-app-workflows-email-domain-setup--verifying-records-in-place--dark:+ hash: v1.k794b7964.7acd8db286c89036d3a56a5b96a1b6279da4d52659c1eb32f55c4d05298b09aa.6xmCAGJW71CqOAobUA-W5x5KraQ50fkUrmYYn-px5R0+ scenes-app-workflows-email-domain-setup--verifying-records-in-place--light:+ hash: v1.k794b7964.92bb38264cbb48ca93cc59bd3435b2e3e24f0caf3c055736fb7c785cd6008dde.tOzGYN_qDMHl914UQSGJHjIDlCZT73_RhjYYDUyVsaQ+ scenes-app-workflows-email-domain-setup--verifying-temporary-failure--dark:+ hash: v1.k794b7964.f79b47b85a477dab0bde25ac7973a675e7aa68efdf0b9bffea30a226154b2044.M5nsCVGjVDV7Vvwq3w1j_aEAj5e-k9dm8Kz-hjYH09s+ scenes-app-workflows-email-domain-setup--verifying-temporary-failure--light:+ hash: v1.k794b7964.ab1d8f0aca8478018fadfedd1a32d71843fae8ee3a0958ce22355d9d85ec8b15.tX5ayDpCuNehvBFqI-WykJ6q5ERZ0InGagC2ckL-YZkscenes-code-review--default--dark:hash: v1.k794b7964.5a9975a808e98b7353c1eaabf06a9c09a52975af66610be197e6427d322c8494.A_lAa9TF0QYJlpZqdm7QHPEa7Dj7Ayj7xMlHeq2BGycscenes-code-review--default--light:diff --git a/frontend/src/productScenes.tsx b/frontend/src/productScenes.tsxindex a648298fb81a..1c47525f73d5 100644--- a/frontend/src/productScenes.tsx+++ b/frontend/src/productScenes.tsx@@ -215,4 +215,5 @@ export const productScenes: Record<string, () => Promise<any>> = {WorkflowsLibraryTemplate: () => import('../../products/workflows/frontend/TemplateLibrary/MessageTemplate'),Broadcasts: () => import('../../products/workflows/frontend/Broadcasts/BroadcastsScene'),Broadcast: () => import('../../products/workflows/frontend/Broadcasts/BroadcastScene'),+ WorkflowsEmailDomain: () => import('../../products/workflows/frontend/Channels/EmailDomain/EmailDomainScene'),}diff --git a/frontend/src/products.tsx b/frontend/src/products.tsxindex 54e63121e954..937488473707 100644--- a/frontend/src/products.tsx+++ b/frontend/src/products.tsx@@ -369,6 +369,7 @@ export const productRoutes: Record<string, [string, string]> = {'/wizard/runs': ['WizardRuns', 'wizardRuns'],'/workflows': ['Workflows', 'workflows'],'/workflows/:tab': ['Workflows', 'workflows'],+ '/workflows/channels/email/:id': ['WorkflowsEmailDomain', 'workflowsEmailDomain'],'/workflows/:id/:tab': ['Workflow', 'workflowTab'],'/workflows/library/templates/:id': ['WorkflowsLibraryTemplate', 'workflowsLibraryTemplate'],'/workflows/library/templates/new': ['WorkflowsLibraryTemplate', 'workflowsLibraryTemplate'],@@ -1321,6 +1322,7 @@ export const productConfiguration: Record<string, any> = {projectBased: true,description: 'Send a one-time or scheduled email to a group of people',},+ WorkflowsEmailDomain: { name: 'Workflows', iconType: 'workflows', projectBased: true },}/** This const is auto-generated, as is the whole file */@@ -2422,7 +2424,14 @@ export const getTreeItemsProducts = (): FileSystemImport[] => [iconType: 'broadcasts',iconColor: ['var(--color-product-broadcasts-light)', 'var(--color-product-broadcasts-dark)'],sceneKey: 'Broadcasts',- sceneKeys: ['Workflows', 'Workflow', 'WorkflowsLibraryTemplate', 'Broadcasts', 'Broadcast'],+ sceneKeys: [+ 'Workflows',+ 'Workflow',+ 'WorkflowsLibraryTemplate',+ 'Broadcasts',+ 'Broadcast',+ 'WorkflowsEmailDomain',+ ],},{path: 'Business intelligence',@@ -3356,7 +3365,14 @@ export const getTreeItemsProducts = (): FileSystemImport[] => [iconType: 'workflows',iconColor: ['var(--color-product-workflows-light)'] as FileSystemIconColor,sceneKey: 'Workflows',- sceneKeys: ['Workflows', 'Workflow', 'WorkflowsLibraryTemplate', 'Broadcasts', 'Broadcast'],+ sceneKeys: [+ 'Workflows',+ 'Workflow',+ 'WorkflowsLibraryTemplate',+ 'Broadcasts',+ 'Broadcast',+ 'WorkflowsEmailDomain',+ ],},]diff --git a/frontend/src/scenes/sceneTypes.ts b/frontend/src/scenes/sceneTypes.tsindex 21f734e6a674..45b0ec54f584 100644--- a/frontend/src/scenes/sceneTypes.ts+++ b/frontend/src/scenes/sceneTypes.ts@@ -458,6 +458,7 @@ export const sceneToAccessControlResourceType: Partial<[Scene.Broadcasts]: AccessControlResourceType.Workflow,[Scene.Workflows]: AccessControlResourceType.Workflow,[Scene.Broadcast]: AccessControlResourceType.Workflow,+ [Scene.WorkflowsEmailDomain]: AccessControlResourceType.Workflow,// Product Tours[Scene.ProductTour]: AccessControlResourceType.ProductTour,diff --git a/products/workflows/frontend/Channels/EmailDomain/BindEmailDomainLogics.tsx b/products/workflows/frontend/Channels/EmailDomain/BindEmailDomainLogics.tsxnew file mode 100644index 000000000000..d5d9de0d5b08--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/BindEmailDomainLogics.tsx@@ -0,0 +1,31 @@+import { BindLogic } from 'kea'+import { ReactNode } from 'react'++import { emailDomainAgentLogic } from './emailDomainAgentLogic'+import { emailDomainAutoConfigureLogic } from './emailDomainAutoConfigureLogic'+import { emailDomainLogic } from './emailDomainLogic'+import { EmailDomainLogicProps } from './emailDomainLogicProps'+import { emailDomainManualSetupLogic } from './emailDomainManualSetupLogic'+import { emailDomainSenderLogic } from './emailDomainSenderLogic'+import { emailDomainStatusLogic } from './emailDomainStatusLogic'++const LOGICS = [+ emailDomainSenderLogic,+ emailDomainStatusLogic,+ emailDomainAutoConfigureLogic,+ emailDomainManualSetupLogic,+ emailDomainAgentLogic,+ emailDomainLogic,+]++/** Binds every logic of the sending domain page to one integration id, so the steps below can use them without props. */+export function BindEmailDomainLogics({ id, children }: EmailDomainLogicProps & { children: ReactNode }): JSX.Element {+ return LOGICS.reduceRight(+ (inner, logic) => (+ <BindLogic logic={logic} props={{ id }}>+ {inner}+ </BindLogic>+ ),+ <>{children}</>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/EmailDomain.stories.tsx b/products/workflows/frontend/Channels/EmailDomain/EmailDomain.stories.tsxnew file mode 100644index 000000000000..fafe232c3e50--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/EmailDomain.stories.tsx@@ -0,0 +1,180 @@+import { Meta, StoryObj } from '@storybook/react'+import { useEffect, useMemo } from 'react'++import { FEATURE_FLAGS } from 'lib/constants'++import { useStorybookMocks } from '~/mocks/browser'++import { FakeDnsHost, FakeEmailDomainBackend, FakeRecord } from './__mocks__/fakeEmailDomainBackend'+import { emailDomainAgentLogic } from './emailDomainAgentLogic'+import { emailDomainManualSetupLogic } from './emailDomainManualSetupLogic'+import { EmailDomainScene } from './EmailDomainScene'+import { emailDomainStatusLogic } from './emailDomainStatusLogic'++const DOMAIN = 'mail.acme.com'+const EMAIL = `hello@${DOMAIN}`++const halfPublished = (record: FakeRecord, index: number): boolean =>+ ['verification', 'spf'].includes(record.kind) || (record.kind === 'dkim' && index < 3)+const allButOneDkimPublished = (_: FakeRecord, index: number): boolean => index !== 2++type Stage = (backend: FakeEmailDomainBackend, id: string) => void++interface DomainPageArgs {+ host: FakeDnsHost+ seed?: (backend: FakeEmailDomainBackend) => void+ stage?: Stage+}++const seededBackend = (host: FakeDnsHost, seed?: DomainPageArgs['seed']): FakeEmailDomainBackend => {+ const backend = new FakeEmailDomainBackend()+ backend.hostDnsAt('acme.com', host)+ backend.addSender({ email: EMAIL })+ seed?.(backend)+ return backend+}++function Staged({ backend, id, stage }: { backend: FakeEmailDomainBackend; id: string; stage?: Stage }): null {+ useEffect(() => {+ stage?.(backend, id)+ }, [backend, id, stage])+ return null+}++function DomainPage({ host, seed, stage }: DomainPageArgs): JSX.Element {+ const backend = useMemo(() => seededBackend(host, seed), [host, seed])+ const id = String(backend.sender(42)?.id)+ useStorybookMocks(backend.mocks())+ return (+ <>+ <EmailDomainScene id={id} />+ <Staged backend={backend} id={id} stage={stage} />+ </>+ )+}++function UnavailableDomainPage(): JSX.Element {+ const backend = useMemo(() => {+ const seeded = seededBackend('unknown')+ seeded.fail('integration_get', { status: 500, body: { detail: 'Could not reach the email provider' } })+ return seeded+ }, [])+ useStorybookMocks(backend.mocks())+ return <EmailDomainScene id="42" />+}++function NewDomainPage(): JSX.Element {+ const backend = useMemo(() => {+ const empty = new FakeEmailDomainBackend()+ empty.eventHosts = [+ ['https://acme.com', 1_240_000],+ ['https://app.acme.com', 860_000],+ ]+ return empty+ }, [])+ useStorybookMocks(backend.mocks())+ return <EmailDomainScene id="new" />+}++const meta: Meta<DomainPageArgs> = {+ title: 'Scenes-App/Workflows/Email domain setup',+ parameters: {+ layout: 'fullscreen',+ featureFlags: [FEATURE_FLAGS.WORKFLOWS_EMAIL_DOMAIN_WIZARD],+ testOptions: { waitForLoadersToDisappear: true },+ },+ render: (args) => <DomainPage {...args} />,+}+export default meta++type Story = StoryObj<DomainPageArgs>++// The checking step keeps its spinner while it polls, so the snapshot cannot wait for loaders to clear.+const pollingStory = { testOptions: { waitForLoadersToDisappear: false } }++export const DomainStep: Story = { render: () => <NewDomainPage /> }++export const SettingsNotStarted: Story = {+ args: { host: 'cloudflare', seed: (backend) => backend.withoutSesIdentity(DOMAIN) },+}++export const SettingsCloudflare: Story = { args: { host: 'cloudflare' } }++export const SettingsCloudflareExistingDmarc: Story = {+ args: { host: 'cloudflare', seed: (backend) => backend.preexistingRecords(DOMAIN, ['dmarc']) },+}++export const SettingsCloudflareRecordsRevealed: Story = {+ args: {+ host: 'cloudflare',+ stage: (_, id) => emailDomainManualSetupLogic.findMounted({ id })?.actions.revealRecords(),+ },+}++export const SettingsRoute53: Story = { args: { host: 'route53' } }++export const SettingsUnknownHost: Story = { args: { host: 'unknown' } }++export const Verifying: Story = {+ args: { host: 'route53', seed: (backend) => backend.publishRecords(DOMAIN, halfPublished) },+ parameters: pollingStory,+}++export const VerifyingRecordsFound: Story = {+ args: { host: 'cloudflare', seed: (backend) => backend.publishRecords(DOMAIN) },+ parameters: pollingStory,+}++export const VerifyingPollingStopped: Story = {+ args: {+ host: 'route53',+ seed: (backend) => backend.publishRecords(DOMAIN, halfPublished),+ stage: (_, id) => emailDomainStatusLogic.findMounted({ id })?.actions.stopPolling(),+ },+}++export const VerifyingRecordsInPlace: Story = {+ args: {+ host: 'cloudflare',+ seed: (backend) => backend.publishRecords(DOMAIN),+ stage: (_, id) => emailDomainStatusLogic.findMounted({ id })?.actions.stopPolling(),+ },+ parameters: pollingStory,+}++export const VerifyingTemporaryFailure: Story = {+ args: {+ host: 'unknown',+ seed: (backend) => {+ backend.sesConfirms(DOMAIN, ['verification', 'dkim'])+ backend.publishRecords(DOMAIN, ['spf', 'dmarc'])+ backend.sesReports(DOMAIN, 'temporary_failure')+ },+ },+ parameters: pollingStory,+}++export const VerifyingFailed: Story = {+ args: {+ host: 'route53',+ seed: (backend) => {+ backend.publishRecords(DOMAIN, allButOneDkimPublished)+ backend.sesReports(DOMAIN, 'failed')+ },+ },+ parameters: pollingStory,+}++export const Ready: Story = { args: { host: 'cloudflare', seed: (backend) => backend.verifyDomain(DOMAIN) } }++export const Unavailable: Story = { render: () => <UnavailableDomainPage /> }++export const AgentHandoff: Story = {+ args: {+ host: 'route53',+ stage: (_, id) => emailDomainAgentLogic.findMounted({ id })?.actions.openAgentModal(),+ },+ parameters: {+ featureFlags: [FEATURE_FLAGS.WORKFLOWS_EMAIL_DOMAIN_WIZARD, FEATURE_FLAGS.WORKFLOWS_EMAIL_DOMAIN_AGENT_SETUP],+ },+}diff --git a/products/workflows/frontend/Channels/EmailDomain/EmailDomainScene.test.tsx b/products/workflows/frontend/Channels/EmailDomain/EmailDomainScene.test.tsxnew file mode 100644index 000000000000..eb101d6ee576--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/EmailDomainScene.test.tsx@@ -0,0 +1,371 @@+import '@testing-library/jest-dom'++import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'+import { Provider, useValues } from 'kea'+import { router } from 'kea-router'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { urls } from 'scenes/urls'++import { resumeKeaLoadersErrors, silenceKeaLoadersErrors } from '~/initKea'+import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { FakeEmailDomainBackend } from './__mocks__/fakeEmailDomainBackend'+import { EmailDomainScene } from './EmailDomainScene'++const DOMAIN = 'mail.acme.com'+const SENDER_ID = 42+const POLL_MS = 10_000++/** Renders the scene for whichever sender the URL names, the way the scene router does in the app. */+function RoutedScene(): JSX.Element {+ const { location } = useValues(router)+ const id = location.pathname.match(/\/workflows\/channels\/email\/([^/]+)/)?.[1] ?? 'new'+ return <EmailDomainScene id={id} />+}++const element = (attr: string): HTMLElement => {+ const found = document.querySelector<HTMLElement>(`[data-attr="${attr}"]`)+ if (!found) {+ throw new Error(`No element with data-attr ${attr} on the page`)+ }+ return found+}++const click = (attr: string): void => {+ fireEvent.click(element(attr))+}++const typeInto = (id: string, value: string): void => {+ fireEvent.change(document.getElementById(id) as HTMLInputElement, { target: { value } })+}++const flush = async (ms = 0): Promise<void> => {+ await act(async () => {+ await jest.advanceTimersByTimeAsync(ms)+ })+}++const expectStep = (title: string | RegExp): void => {+ expect(screen.getByText(title)).toBeInTheDocument()+}++const expectProgress = (text: string): void => {+ expect(screen.getAllByText(text).length).toBeGreaterThan(0)+}++describe('EmailDomainScene', () => {+ let backend: FakeEmailDomainBackend++ const open = async (path: string): Promise<void> => {+ router.actions.push(path)+ render(+ <Provider>+ <RoutedScene />+ </Provider>+ )+ await flush()+ }++ const seedSender = (): void => {+ backend.addSender({ email: `hello@${DOMAIN}` })+ }++ beforeEach(() => {+ jest.useFakeTimers()+ backend = new FakeEmailDomainBackend()+ backend.hostDnsAt('acme.com', 'cloudflare')+ useMocks(backend.mocks())+ initKeaTests()+ featureFlagLogic.mount()+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.WORKFLOWS_EMAIL_DOMAIN_WIZARD], {+ [FEATURE_FLAGS.WORKFLOWS_EMAIL_DOMAIN_WIZARD]: true,+ })+ })++ afterEach(() => {+ cleanup()+ jest.useRealTimers()+ jest.restoreAllMocks()+ })++ it('takes a typed domain through the manual path to a verified first sender', async () => {+ await open(urls.workflowsEmailDomain('new'))+ expectStep('Which domain should your emails come from?')++ typeInto('email-domain-another-domain', 'acme.com')+ click('email-domain-use-custom-domain')+ expect(screen.getByText('[email protected]')).toBeInTheDocument()+ typeInto('email-domain-sender-name-input', 'Support team')+ typeInto('email-domain-local-part', 'support')+ expect(screen.getByText('[email protected]')).toBeInTheDocument()++ // Tests run as a local stack, which starts on Maildev.+ click('email-domain-local-provider-ses')+ click('email-domain-continue')+ await flush()+ expect(backend.requestsTo('integration_create')[0].body).toEqual({+ kind: 'email',+ config: {+ email: '[email protected]',+ name: 'Support team',+ provider: 'ses',+ mail_from_subdomain: 'feedback',+ },+ })+ expect(router.values.location.pathname).toMatch(new RegExp(`${urls.workflowsEmailDomain(SENDER_ID)}$`))+ expectStep('Add 8 settings at Cloudflare')++ click('email-domain-reveal-records')+ await flush()+ expect(screen.getByText('Proves you own the domain')).toBeInTheDocument()+ expect(backend.requestsTo('email_update').map((request) => request.body)).toEqual([+ { config: expect.objectContaining({ setup_method: 'manual' }) },+ ])+ expect(backend.senderConfig(SENDER_ID)?.setup_method).toBe('manual')++ backend.publishRecords(DOMAIN)+ await flush(POLL_MS)+ expectStep('Checking your settings…')+ expectProgress('8 of 8 found')++ backend.verifyDomain(DOMAIN)+ await flush(POLL_MS)+ expectStep(/You can send from/)++ typeInto('email-domain-sender-name', 'Acme Team')+ click('email-domain-save-sender-name')+ await flush()+ expect(backend.senderConfig(SENDER_ID)?.name).toBe('Acme Team')+ expect(document.querySelector('[data-attr="email-domain-save-sender-name"]')).toBeNull()++ click('email-domain-send-test-email')+ await flush()+ const invocation = backend.requestsTo('test_email')[0].body as any+ const emailInput = invocation.configuration.actions[1].config.inputs.email.value+ expect(emailInput.from).toEqual({ integrationId: SENDER_ID })+ expect(emailInput.to.email).toBe(invocation.globals.person.properties.email)+ expect(screen.getByText('Send another test')).toBeInTheDocument()+ })++ it('sends the person to Cloudflare and verifies after they return', async () => {+ seedSender()+ const tab = { location: { href: '' }, opener: {}, close: jest.fn() }+ jest.spyOn(window, 'open').mockReturnValue(tab as unknown as Window)+ await open(urls.workflowsEmailDomain(SENDER_ID))+ expectStep('Add 8 settings at Cloudflare')++ click('email-domain-auto-configure')+ await flush()+ const returnUrl = `http://localhost/project/997${urls.workflowsEmailDomain(SENDER_ID)}?domain_connect=email`+ expect(backend.requestsTo('domain_connect_apply_url')[0].body).toEqual({+ context: 'email',+ integration_id: SENDER_ID,+ redirect_uri: returnUrl,+ })+ expect(tab.location.href).toContain(`redirect_uri=${encodeURIComponent(returnUrl)}`)+ expect(backend.senderConfig(SENDER_ID)?.setup_method).toBe('auto')++ backend.approveDomainConnect(DOMAIN)+ cleanup()+ await open(`${urls.workflowsEmailDomain(SENDER_ID)}?domain_connect=email`)+ expect(router.values.location.search).toBe('')+ expect(backend.requestsTo('email_status').at(-1)?.url).toContain('refresh=true')+ expectStep('Checking your settings…')+ expectProgress('8 of 8 found')++ backend.verifyDomain(DOMAIN)+ await flush(POLL_MS)+ expectStep(/You can send from/)+ })++ it('stays on the settings when the return from Cloudflare brought no records, and still finds them later', async () => {+ seedSender()+ await open(`${urls.workflowsEmailDomain(SENDER_ID)}?domain_connect=email`)+ expectStep('Checking your settings…')+ expectProgress('0 of 8 found')+ expect(backend.senderConfig(SENDER_ID)?.verified).toBe(false)++ backend.publishRecords(DOMAIN)+ await flush(POLL_MS)+ expectProgress('8 of 8 found')+ backend.verifyDomain(DOMAIN)+ await flush(POLL_MS)+ expectStep(/You can send from/)+ })++ it('refuses a second submit while creating, shows the error, and lets the person try again', async () => {+ const release = backend.hold('integration_create')+ backend.failOnce('integration_create', {+ status: 400,+ body: { detail: 'This domain is already used by another organization' },+ })+ await open(urls.workflowsEmailDomain('new'))+ typeInto('email-domain-another-domain', 'acme.com')+ click('email-domain-use-custom-domain')++ click('email-domain-continue')+ click('email-domain-continue')+ await flush()+ expect(backend.requestsTo('integration_create')).toHaveLength(1)++ silenceKeaLoadersErrors()+ release()+ await flush()+ resumeKeaLoadersErrors()+ expect(screen.getByText('This domain is already used by another organization')).toBeInTheDocument()+ expect(router.values.location.pathname).toMatch(/\/new$/)++ click('email-domain-continue')+ await flush()+ expect(backend.requestsTo('integration_create')).toHaveLength(2)+ expectStep('Add 8 settings at Cloudflare')+ })++ it('keeps the edited sender name on screen when the save fails, and saves it on the next try', async () => {+ seedSender()+ backend.verifyDomain(DOMAIN)+ backend.failOnce('email_update', { status: 500, body: { detail: 'Could not reach the email provider' } })+ await open(urls.workflowsEmailDomain(SENDER_ID))+ expectStep(/You can send from/)++ typeInto('email-domain-sender-name', 'Acme Team')+ click('email-domain-save-sender-name')+ await flush()+ expect(document.getElementById('email-domain-sender-name')).toHaveValue('Acme Team')+ expect(backend.senderConfig(SENDER_ID)?.name).toBe('Acme')++ click('email-domain-save-sender-name')+ await flush()+ expect(backend.senderConfig(SENDER_ID)?.name).toBe('Acme Team')+ expect(document.querySelector('[data-attr="email-domain-save-sender-name"]')).toBeNull()+ })++ it('offers try again when the sender does not load, then shows the settings', async () => {+ seedSender()+ backend.failOnce('integration_get', { status: 500, body: { detail: 'Could not reach the email provider' } })+ silenceKeaLoadersErrors()+ await open(urls.workflowsEmailDomain(SENDER_ID))+ resumeKeaLoadersErrors()+ expectStep('We could not load your sending domain')++ click('email-domain-retry')+ await flush()+ expectStep('Add 8 settings at Cloudflare')+ expect(backend.requestsTo('integration_get')).toHaveLength(2)+ })++ it('keeps the progress on screen when a status check fails after the records were found', async () => {+ seedSender()+ backend.publishRecords(DOMAIN)+ await open(urls.workflowsEmailDomain(SENDER_ID))+ expectProgress('8 of 8 found')++ backend.fail('email_status', { status: 503, body: { code: 'ses_unavailable', detail: 'SES is down' } })+ await flush(POLL_MS)+ expectStep('Checking your settings…')+ expectProgress('8 of 8 found')+ expect(document.querySelector('[data-attr="email-domain-retry"]')).toBeNull()++ backend.recover('email_status')+ backend.verifyDomain(DOMAIN)+ await flush(POLL_MS)+ expectStep(/You can send from/)+ })++ it.each([+ ['still confirming', false, 'Your records are in place'],+ ['reporting a temporary failure', true, "The email provider can't confirm your records yet"],+ ])(+ 'describes found records when automatic checks stop while the provider is %s',+ async (_, temporaryFailure, heading) => {+ seedSender()+ backend.publishRecords(DOMAIN)+ if (temporaryFailure) {+ backend.sesReports(DOMAIN, 'temporary_failure')+ }+ await open(urls.workflowsEmailDomain(SENDER_ID))++ await flush(31 * 60_000)+ expectStep(heading)+ expect(screen.queryByText(/still missing/)).not.toBeInTheDocument()+ expect(screen.queryByText(/could not find these settings/)).not.toBeInTheDocument()+ }+ )++ it('falls back to the generic manual setup when host detection fails', async () => {+ seedSender()+ backend.fail('domain_connect_check', { status: 500, body: { detail: 'DNS lookup timed out' } })+ await open(urls.workflowsEmailDomain(SENDER_ID))+ expectStep('Add 8 settings at your DNS host')+ expect(document.querySelector('[data-attr="email-domain-auto-configure"]')).toBeNull()+ expect(element('email-domain-records-added')).toBeInTheDocument()+ })++ it('lets the person restart a stopped verification again after the first restart fails', async () => {+ seedSender()+ backend.sesReports(DOMAIN, 'failed')+ backend.failOnce('email_verify', { status: 500, body: { detail: 'SES is down' } })+ await open(urls.workflowsEmailDomain(SENDER_ID))+ expectStep('Verification stopped')++ click('email-domain-restart-verification')+ await flush()+ expectStep('Verification stopped')+ expect(element('email-domain-restart-verification')).not.toHaveAttribute('aria-disabled', 'true')++ click('email-domain-restart-verification')+ await flush()+ expect(backend.requestsTo('email_verify')).toHaveLength(2)+ expectStep('Add 8 settings at Cloudflare')+ })+ it.each([+ ['skipped', { status: 'skipped', reason: 'The recipient has no reachable mail servers.' }],+ ['unknown', undefined],+ ['failed', { status: 'failed', reason: 'The provider refused the message.' }],+ ])('does not claim a test email was sent when the send result is %s', async (_, emailSendResult) => {+ seedSender()+ backend.verifyDomain(DOMAIN)+ const mocks = backend.mocks()+ useMocks({+ ...mocks,+ post: {+ ...mocks.post,+ '/api/environments/:team_id/hog_flows/:id/invocations/': () => ({+ status: 'success',+ nextActionId: 'exit_node',+ logs: [],+ emailSendResult,+ }),+ },+ })+ await open(urls.workflowsEmailDomain(SENDER_ID))+ click('email-domain-send-test-email')+ await flush()+ expect(screen.queryByText('Send another test')).not.toBeInTheDocument()+ expect(screen.getByText('Send me a test email')).toBeInTheDocument()+ })++ it('offers another test only after the email provider accepted the message', async () => {+ seedSender()+ backend.verifyDomain(DOMAIN)+ const mocks = backend.mocks()+ useMocks({+ ...mocks,+ post: {+ ...mocks.post,+ '/api/environments/:team_id/hog_flows/:id/invocations/': () => ({+ status: 'success',+ nextActionId: 'exit_node',+ emailSendResult: { status: 'accepted' },+ }),+ },+ })+ await open(urls.workflowsEmailDomain(SENDER_ID))+ click('email-domain-send-test-email')+ await flush()+ expect(screen.getByText('Send another test')).toBeInTheDocument()+ })+})diff --git a/products/workflows/frontend/Channels/EmailDomain/EmailDomainScene.tsx b/products/workflows/frontend/Channels/EmailDomain/EmailDomainScene.tsxnew file mode 100644index 000000000000..6f9a07f1d83e--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/EmailDomainScene.tsx@@ -0,0 +1,32 @@+import { useValues } from 'kea'++import { NotFound } from 'lib/components/NotFound'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { SceneExport } from 'scenes/sceneTypes'++import { ProductKey } from '~/queries/schema/schema-general'++import { BindEmailDomainLogics } from './BindEmailDomainLogics'+import { emailDomainLogic } from './emailDomainLogic'+import { EmailDomainLogicProps } from './emailDomainLogicProps'+import { EmailDomainSetup } from './EmailDomainSetup'++export const scene: SceneExport<EmailDomainLogicProps> = {+ component: EmailDomainScene,+ logic: emailDomainLogic,+ paramsToProps: ({ params: { id } }): EmailDomainLogicProps => ({ id: id || 'new' }),+ productKey: ProductKey.WORKFLOWS,+}++export function EmailDomainScene({ id }: EmailDomainLogicProps): JSX.Element {+ const { featureFlags } = useValues(featureFlagLogic)+ if (!featureFlags[FEATURE_FLAGS.WORKFLOWS_EMAIL_DOMAIN_WIZARD]) {+ return <NotFound object="page" />+ }+ return (+ <BindEmailDomainLogics id={id || 'new'}>+ <EmailDomainSetup />+ </BindEmailDomainLogics>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/EmailDomainSetup.tsx b/products/workflows/frontend/Channels/EmailDomain/EmailDomainSetup.tsxnew file mode 100644index 000000000000..a29a9afd22b7--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/EmailDomainSetup.tsx@@ -0,0 +1,57 @@+import { useValues } from 'kea'+import { router } from 'kea-router'++import { LemonSkeleton } from '@posthog/lemon-ui'++import { urls } from 'scenes/urls'++import { AgentHandoffModal } from './components/AgentHandoffModal'+import { StepIndicator } from './components/StepIndicator'+import { emailDomainLogic } from './emailDomainLogic'+import { DomainStep } from './steps/DomainStep'+import { ReadyStep } from './steps/ReadyStep'+import { SettingsStep } from './steps/SettingsStep'+import { UnavailableStep } from './steps/UnavailableStep'+import { VerifyingStep } from './steps/VerifyingStep'++function CurrentStep(): JSX.Element {+ const { phase } = useValues(emailDomainLogic)+ switch (phase) {+ case 'domain':+ return (+ <DomainStep+ logicKey="page"+ onCreated={(integration) => router.actions.replace(urls.workflowsEmailDomain(integration.id))}+ />+ )+ case 'loading':+ return (+ <div className="flex flex-col gap-4">+ <LemonSkeleton className="h-32" />+ <LemonSkeleton className="h-12" />+ <LemonSkeleton className="h-40" />+ </div>+ )+ case 'unavailable':+ return <UnavailableStep />+ case 'settings':+ return <SettingsStep />+ case 'verifying':+ return <VerifyingStep />+ case 'ready':+ return <ReadyStep />+ }+}++export function EmailDomainSetup(): JSX.Element {+ const { phase } = useValues(emailDomainLogic)+ return (+ <div className="@container flex flex-col items-center px-4 py-8 @3xl:py-14">+ <div className="w-full max-w-160 flex flex-col gap-8">+ <StepIndicator phase={phase} />+ <CurrentStep />+ </div>+ <AgentHandoffModal />+ </div>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/AgentHandoffModal.tsx b/products/workflows/frontend/Channels/EmailDomain/components/AgentHandoffModal.tsxnew file mode 100644index 000000000000..bcc42a21d6d9--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/AgentHandoffModal.tsx@@ -0,0 +1,92 @@+import { useActions, useValues } from 'kea'++import { IconCopy, IconExternal } from '@posthog/icons'+import { LemonButton, LemonCheckbox, LemonModal } from '@posthog/lemon-ui'++import { emailDomainAgentLogic } from '../emailDomainAgentLogic'+import { emailDomainAutoConfigureLogic } from '../emailDomainAutoConfigureLogic'+import { emailDomainStatusLogic } from '../emailDomainStatusLogic'+import { HedgehogRobot } from '../hoggies'++function AgentSteps({+ host,+ recordCount,+ usesBrowser,+}: {+ host: string+ recordCount: number+ usesBrowser: boolean+}): JSX.Element {+ return (+ <ol className="list-decimal pl-5 text-sm text-secondary space-y-0.5">+ {usesBrowser ? (+ <>+ <li>Opens {host} in a browser you are signed in to</li>+ <li>Adds the {recordCount} records without touching anything else</li>+ <li>Comes back here and clicks Check again until you are ready to send</li>+ </>+ ) : (+ <>+ <li>Reads the records through the PostHog MCP tools</li>+ <li>Adds them at {host} through its API, or hands you an approval link</li>+ <li>Polls PostHog until you are ready to send</li>+ </>+ )}+ </ol>+ )+}++export function AgentHandoffModal(): JSX.Element {+ const { agentModalOpen, agentUsesBrowser, setupPrompt, claudeUrl } = useValues(emailDomainAgentLogic)+ const { closeAgentModal, setAgentUsesBrowser, copyPrompt, promptOpenedInClaude } = useActions(emailDomainAgentLogic)+ const { hostName } = useValues(emailDomainAutoConfigureLogic)+ const { records } = useValues(emailDomainStatusLogic)+ const host = hostName ?? 'your DNS host'++ return (+ <LemonModal+ isOpen={agentModalOpen}+ onClose={closeAgentModal}+ title="Let an agent add the settings"+ description="Your coding agent gets the exact records plus the checks it should run. You stay in control of the approval."+ width={640}+ footer={+ <div className="flex flex-wrap gap-2 justify-end">+ <LemonButton+ type="secondary"+ icon={<IconCopy />}+ onClick={copyPrompt}+ data-attr="email-domain-copy-prompt"+ >+ Copy prompt+ </LemonButton>+ <LemonButton+ type="primary"+ icon={<IconExternal />}+ to={claudeUrl}+ targetBlank+ onClick={promptOpenedInClaude}+ data-attr="email-domain-open-in-claude"+ >+ Open in Claude+ </LemonButton>+ </div>+ }+ >+ <div className="flex flex-col gap-4">+ <div className="flex gap-4 items-start">+ <HedgehogRobot className="w-20 shrink-0" />+ <LemonCheckbox+ checked={agentUsesBrowser}+ onChange={setAgentUsesBrowser}+ label={`My agent can use a browser. Let it sign in to ${host} and add the records itself.`}+ />+ </div>+ <AgentSteps host={host} recordCount={records.length} usesBrowser={agentUsesBrowser} />+ <pre className="text-xs whitespace-pre-wrap border rounded bg-fill-primary p-3 max-h-60 overflow-auto m-0">+ {setupPrompt}+ </pre>+ </div>+ </LemonModal>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/AgentSetupButton.tsx b/products/workflows/frontend/Channels/EmailDomain/components/AgentSetupButton.tsxnew file mode 100644index 000000000000..0ba3cbe27c00--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/AgentSetupButton.tsx@@ -0,0 +1,24 @@+import { useActions, useValues } from 'kea'++import { IconSparkles } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { emailDomainAgentLogic } from '../emailDomainAgentLogic'++export function AgentSetupButton(): JSX.Element | null {+ const { agentSetupEnabled } = useValues(emailDomainAgentLogic)+ const { openAgentModal } = useActions(emailDomainAgentLogic)+ if (!agentSetupEnabled) {+ return null+ }+ return (+ <LemonButton+ type="tertiary"+ icon={<IconSparkles />}+ onClick={openAgentModal}+ data-attr="email-domain-agent-setup"+ >+ Let an agent do it+ </LemonButton>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/AnotherDomainInput.tsx b/products/workflows/frontend/Channels/EmailDomain/components/AnotherDomainInput.tsxnew file mode 100644index 000000000000..60d3fd9d65af--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/AnotherDomainInput.tsx@@ -0,0 +1,47 @@+import { useActions, useValues } from 'kea'++import { IconArrowRight } from '@posthog/icons'+import { LemonButton, LemonInput } from '@posthog/lemon-ui'++import { DomainProblem } from '../domainInput'+import { EmailDomainWizardLogicProps, emailDomainWizardLogic } from '../emailDomainWizardLogic'++const PROBLEM_COPY: Record<DomainProblem, string> = {+ free_mailbox: 'That is a free mailbox provider. Use a domain you own, like yourcompany.com.',+ invalid: 'That does not look like a domain. Try something like yourcompany.com.',+}++export function AnotherDomainInput(props: EmailDomainWizardLogicProps): JSX.Element {+ const logic = emailDomainWizardLogic(props)+ const { customDomainInput, customDomain } = useValues(logic)+ const { setCustomDomainInput, useCustomDomain } = useActions(logic)+ const canUse = Boolean(customDomain.domain) && !customDomain.problem+ return (+ <div className="flex flex-col gap-1.5">+ <label className="text-sm text-secondary" htmlFor="email-domain-another-domain">+ Another domain+ </label>+ <div className="flex gap-2">+ <LemonInput+ id="email-domain-another-domain"+ className="flex-1 font-mono"+ placeholder="yourcompany.com"+ value={customDomainInput}+ onChange={setCustomDomainInput}+ onPressEnter={useCustomDomain}+ status={customDomain.problem ? 'danger' : undefined}+ />+ <LemonButton+ type="secondary"+ onClick={useCustomDomain}+ disabledReason={canUse ? undefined : 'Type a domain you own'}+ icon={<IconArrowRight />}+ data-attr="email-domain-use-custom-domain"+ >+ Use+ </LemonButton>+ </div>+ {customDomain.problem && <span className="text-xs text-danger">{PROBLEM_COPY[customDomain.problem]}</span>}+ </div>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/BigAction.tsx b/products/workflows/frontend/Channels/EmailDomain/components/BigAction.tsxnew file mode 100644index 000000000000..d9cfba8a1ed4--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/BigAction.tsx@@ -0,0 +1,9 @@+import { LemonButton, LemonButtonProps } from '@posthog/lemon-ui'++export function BigAction({ children, ...props }: LemonButtonProps): JSX.Element {+ return (+ <LemonButton type="primary" size="large" fullWidth center className="text-base" {...props}>+ {children}+ </LemonButton>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/DnsHostLink.tsx b/products/workflows/frontend/Channels/EmailDomain/components/DnsHostLink.tsxnew file mode 100644index 000000000000..72689b66c08c--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/DnsHostLink.tsx@@ -0,0 +1,27 @@+import { useValues } from 'kea'++import { IconExternal } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { emailDomainAutoConfigureLogic } from '../emailDomainAutoConfigureLogic'++export function DnsHostLink({ primary }: { primary?: boolean }): JSX.Element | null {+ const { dnsHost } = useValues(emailDomainAutoConfigureLogic)+ if (!dnsHost) {+ return null+ }+ return (+ <LemonButton+ type={primary ? 'primary' : 'tertiary'}+ size={primary ? 'large' : undefined}+ fullWidth={primary}+ center={primary}+ to={dnsHost.dns_settings_url}+ targetBlank+ sideIcon={<IconExternal />}+ data-attr="email-domain-open-dns-host"+ >+ Open {dnsHost.name}+ </LemonButton>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/DnsRecordRows.tsx b/products/workflows/frontend/Channels/EmailDomain/components/DnsRecordRows.tsxnew file mode 100644index 000000000000..625d6014b168--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/DnsRecordRows.tsx@@ -0,0 +1,131 @@+import clsx from 'clsx'+import posthog from 'posthog-js'++import { IconCheck, IconCopy, IconHourglass, IconWarning } from '@posthog/icons'+import { LemonButton, LemonTag, lemonToast } from '@posthog/lemon-ui'++import { copyToClipboard } from 'lib/utils/copyToClipboard'++import type {+ EmailDomainSetupRecordKindEnumApi,+ EmailDomainStatusRecordApi,+} from 'products/integrations/frontend/generated/api.schemas'++export const RECORD_KIND_LABEL: Record<EmailDomainSetupRecordKindEnumApi, string> = {+ verification: 'Proves you own the domain',+ dkim: 'Signs your emails (DKIM)',+ spf: 'Lists who may send for you (SPF)',+ mail_from_mx: 'Routes bounces back to you (MAIL FROM)',+ mail_from_spf: 'Lists who may send bounces (MAIL FROM SPF)',+ dmarc: 'Tells inboxes what to do with fakes (DMARC)',+}++const RECORD_KIND_HINT: Partial<Record<EmailDomainSetupRecordKindEnumApi, string>> = {+ spf: 'Already have an SPF record at this name? Add include:amazonses.com to it instead of adding a second one.',+ mail_from_spf:+ 'Already have an SPF record at this name? Add include:amazonses.com to it instead of adding a second one.',+ dmarc: 'Already have a DMARC record? Keep yours and skip this one.',+}++type RowStatus = EmailDomainStatusRecordApi['status'] | 'missing'++const ROW_STATUS: Record<RowStatus, { label: string; icon: JSX.Element; className: string }> = {+ pending: { label: 'Not found yet', icon: <IconHourglass />, className: 'text-secondary' },+ found: { label: 'Found', icon: <IconCheck />, className: 'text-success' },+ verified: { label: 'Verified', icon: <IconCheck />, className: 'text-success' },+ missing: { label: 'Missing', icon: <IconWarning />, className: 'text-danger' },+}++function CopyField({+ label,+ value,+ record,+}: {+ label: string+ value: string+ record: EmailDomainStatusRecordApi+}): JSX.Element {+ const copy = async (): Promise<void> => {+ if (await copyToClipboard(value, label, { silent: true })) {+ // pinned: analytics event name+ posthog.capture('email domain records copied', { kind: record.kind, field: label.toLowerCase() })+ lemonToast.success(`Copied the ${label.toLowerCase()}`)+ }+ }+ return (+ <div className="flex flex-col gap-0.5 min-w-0">+ <span className="text-xs text-secondary">{label}</span>+ <div className="flex items-start gap-1">+ <code className="font-mono text-xs break-all bg-fill-primary border rounded px-1.5 py-1 flex-1 min-w-0">+ {value}+ </code>+ <LemonButton+ size="xsmall"+ icon={<IconCopy />}+ tooltip={`Copy ${label.toLowerCase()}`}+ onClick={() => void copy()}+ data-attr="email-domain-copy-record"+ />+ </div>+ </div>+ )+}++export function DnsRecordRows({+ records,+ missing,+ showStatus,+}: {+ records: EmailDomainStatusRecordApi[]+ missing?: EmailDomainStatusRecordApi[]+ showStatus: boolean+}): JSX.Element {+ const rowStatus = (record: EmailDomainStatusRecordApi): RowStatus =>+ missing?.includes(record) ? 'missing' : record.status+ const ordered = missing?.length ? [...missing, ...records.filter((record) => !missing.includes(record))] : records+ return (+ <ol className="m-0 p-0 list-none flex flex-col gap-2" aria-label="Settings to add">+ {ordered.map((record, index) => {+ const status = ROW_STATUS[rowStatus(record)]+ const isMissing = rowStatus(record) === 'missing'+ const hint = isMissing || record.status === 'pending' ? RECORD_KIND_HINT[record.kind] : undefined+ return (+ <li+ key={`${record.type}-${record.hostname}-${index}`}+ className={clsx(+ 'rounded border bg-surface-primary p-3 flex flex-col gap-2',+ isMissing && 'border-danger bg-danger-highlight'+ )}+ >+ <div className="flex flex-wrap items-center gap-2">+ <LemonTag type="default" className="font-mono">+ {record.type}+ </LemonTag>+ <span className="text-sm font-medium">{RECORD_KIND_LABEL[record.kind]}</span>+ {showStatus && (+ <span+ className={clsx(+ 'ml-auto inline-flex items-center gap-1 text-xs whitespace-nowrap',+ status.className+ )}+ >+ {status.icon}+ {status.label}+ </span>+ )}+ </div>+ <div className="grid gap-2 @lg:grid-cols-2">+ <CopyField label="Name" value={record.hostname} record={record} />+ <CopyField+ label={record.priority != null ? `Value (priority ${record.priority})` : 'Value'}+ value={record.value}+ record={record}+ />+ </div>+ {hint && <p className="m-0 text-xs text-secondary">{hint}</p>}+ </li>+ )+ })}+ </ol>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/DomainCard.tsx b/products/workflows/frontend/Channels/EmailDomain/components/DomainCard.tsxnew file mode 100644index 000000000000..8d2ec92187d2--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/DomainCard.tsx@@ -0,0 +1,47 @@+import clsx from 'clsx'++import { IconCheck } from '@posthog/icons'+import { LemonTag } from '@posthog/lemon-ui'++import { InferredDomain } from '../inferDomains'++export function DomainCard({+ domain,+ reasons,+ recommended,+ selected,+ onSelect,+}: InferredDomain & { selected: boolean; onSelect: () => void }): JSX.Element {+ return (+ <button+ type="button"+ onClick={onSelect}+ aria-pressed={selected}+ data-attr="email-domain-pick-domain"+ className={clsx(+ 'w-full text-left rounded-lg border-2 p-4 flex items-start gap-3 transition-colors motion-reduce:transition-none cursor-pointer',+ selected ? 'border-accent bg-accent-highlight-secondary' : 'border-primary bg-surface-primary'+ )}+ >+ <span className="flex flex-col gap-1 min-w-0 flex-1">+ <span className="flex flex-wrap items-center gap-2">+ <span className="font-mono text-lg @md:text-xl font-semibold break-all">{domain}</span>+ {recommended && <LemonTag type="highlight">Recommended</LemonTag>}+ </span>+ {reasons.map((reason) => (+ <span key={reason} className="text-xs text-secondary">+ {reason}+ </span>+ ))}+ </span>+ <span+ className={clsx(+ 'shrink-0 w-6 h-6 rounded-full border-2 inline-flex items-center justify-center',+ selected ? 'bg-accent border-accent text-white' : 'border-primary'+ )}+ >+ {selected && <IconCheck />}+ </span>+ </button>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/FirstSenderCard.tsx b/products/workflows/frontend/Channels/EmailDomain/components/FirstSenderCard.tsxnew file mode 100644index 000000000000..ac19fbbc7556--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/FirstSenderCard.tsx@@ -0,0 +1,91 @@+import { useActions, useValues } from 'kea'++import { IconCheck, IconSend } from '@posthog/icons'+import { LemonButton, LemonInput } from '@posthog/lemon-ui'++import { emailDomainSenderLogic } from '../emailDomainSenderLogic'++function SenderNameField(): JSX.Element {+ const { senderName, senderNameChanged, senderSaving } = useValues(emailDomainSenderLogic)+ const { setSenderName, saveSender } = useActions(emailDomainSenderLogic)+ const canSave = senderNameChanged && Boolean(senderName.trim()) && !senderSaving+ return (+ <div className="flex flex-col gap-1">+ <label className="text-sm" htmlFor="email-domain-sender-name">+ Name+ </label>+ <div className="flex gap-2">+ <LemonInput+ id="email-domain-sender-name"+ className="flex-1"+ value={senderName}+ onChange={setSenderName}+ onPressEnter={canSave ? saveSender : undefined}+ placeholder="Acme"+ />+ {senderNameChanged && (+ <LemonButton+ type="secondary"+ onClick={saveSender}+ loading={senderSaving}+ disabledReason={senderSaving ? 'Saving' : !senderName.trim() ? 'Type a name' : undefined}+ data-attr="email-domain-save-sender-name"+ >+ Save+ </LemonButton>+ )}+ </div>+ </div>+ )+}++function TestEmailButton(): JSX.Element {+ const { testSendResultLoading, testEmailSent, user } = useValues(emailDomainSenderLogic)+ const { sendTestEmail } = useActions(emailDomainSenderLogic)+ return (+ <LemonButton+ type={testEmailSent ? 'secondary' : 'primary'}+ icon={testEmailSent ? <IconCheck /> : <IconSend />}+ loading={testSendResultLoading}+ disabledReason={testSendResultLoading ? 'Sending' : !user?.email ? 'Your account has no email' : undefined}+ onClick={sendTestEmail}+ tooltip={user?.email ? `Sends to ${user.email}` : undefined}+ data-attr="email-domain-send-test-email"+ >+ {testEmailSent ? 'Send another test' : 'Send me a test email'}+ </LemonButton>+ )+}++export function FirstSenderCard(): JSX.Element {+ const { senderName, fromAddress } = useValues(emailDomainSenderLogic)+ return (+ <section className="rounded-lg border bg-surface-primary p-5 flex flex-col gap-4">+ <div className="flex flex-col gap-0.5">+ <h2 className="m-0 text-lg font-semibold">Your first sender</h2>+ <p className="m-0 text-sm text-secondary">The name and address people see in their inbox.</p>+ </div>+ <div className="grid gap-3 @md:grid-cols-2">+ <SenderNameField />+ <div className="flex flex-col gap-1">+ <label className="text-sm" htmlFor="email-domain-sender-address">+ Address+ </label>+ <LemonInput+ id="email-domain-sender-address"+ className="font-mono"+ value={fromAddress ?? ''}+ disabledReason="The address is fixed. To send from another address, set up a new sender and type the full address."+ />+ </div>+ </div>+ <div className="flex flex-wrap items-center justify-between gap-3 rounded bg-fill-primary border px-3 py-2">+ <span className="text-sm min-w-0 break-all">+ <span className="font-medium">{senderName || 'Your name'}</span>{' '}+ <span className="text-secondary font-mono"><{fromAddress}></span>+ </span>+ <TestEmailButton />+ </div>+ </section>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/LocalProviderPicker.tsx b/products/workflows/frontend/Channels/EmailDomain/components/LocalProviderPicker.tsxnew file mode 100644index 000000000000..54bc93c012a8--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/LocalProviderPicker.tsx@@ -0,0 +1,34 @@+import { useActions, useValues } from 'kea'++import { LemonSegmentedButton } from '@posthog/lemon-ui'++import { EmailDomainWizardLogicProps, EmailSenderProvider, emailDomainWizardLogic } from '../emailDomainWizardLogic'++const PROVIDER_NOTES: Record<EmailSenderProvider, string> = {+ maildev: 'Verifies right away. Emails go to the local inbox at localhost:1080.',+ ses: 'Uses the SES account from your local settings. The domain needs real DNS records to verify.',+}++export function LocalProviderPicker(props: EmailDomainWizardLogicProps): JSX.Element | null {+ const logic = emailDomainWizardLogic(props)+ const { isLocalStack, localProvider } = useValues(logic)+ const { setLocalProvider } = useActions(logic)+ if (!isLocalStack) {+ return null+ }+ return (+ <div className="flex flex-col gap-2 rounded border border-dashed p-3">+ <span className="text-sm">Send through (local stack only)</span>+ <LemonSegmentedButton+ size="small"+ value={localProvider}+ onChange={setLocalProvider}+ options={[+ { value: 'maildev', label: 'Maildev', 'data-attr': 'email-domain-local-provider-maildev' },+ { value: 'ses', label: 'Amazon SES', 'data-attr': 'email-domain-local-provider-ses' },+ ]}+ />+ <span className="text-xs text-secondary">{PROVIDER_NOTES[localProvider]}</span>+ </div>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/NextWorkflowCard.tsx b/products/workflows/frontend/Channels/EmailDomain/components/NextWorkflowCard.tsxnew file mode 100644index 000000000000..1341b50ba1b8--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/NextWorkflowCard.tsx@@ -0,0 +1,45 @@+import { useValues } from 'kea'+import { router } from 'kea-router'++import { IconPlus } from '@posthog/icons'+import { Link } from '@posthog/lemon-ui'++import { urls } from 'scenes/urls'++import { emailDomainSenderLogic } from '../emailDomainSenderLogic'+import { HedgehogMailbox } from '../hoggies'+import { BigAction } from './BigAction'++// The id of the "Welcome email sequence" template shipped in products/workflows/backend/templates.+const WELCOME_EMAIL_TEMPLATE_ID = '019b6f44-f9a3-0000-c4a7-b8050d25d690'++export function NextWorkflowCard(): JSX.Element {+ const { domain, senderName, fromAddress } = useValues(emailDomainSenderLogic)+ return (+ <section className="rounded-xl border border-accent bg-accent-highlight-secondary p-6 @md:p-8 flex flex-col gap-5">+ <div className="flex items-start gap-4">+ <HedgehogMailbox className="w-20 shrink-0" />+ <div className="flex flex-col gap-1 min-w-0">+ <span className="text-xs uppercase tracking-wide text-secondary">Next</span>+ <h2 className="m-0 text-xl font-semibold">Send your first email from {domain}</h2>+ <p className="m-0 text-sm text-secondary">+ Start with a welcome email that goes out when someone signs up. We open the Welcome email+ sequence template so you can pick <span className="font-medium">{senderName}</span>{' '}+ <span className="font-mono"><{fromAddress}></span> as the sender.+ </p>+ </div>+ </div>+ <BigAction+ icon={<IconPlus />}+ onClick={() => router.actions.push(urls.workflowNew(), { templateId: WELCOME_EMAIL_TEMPLATE_ID })}+ data-attr="email-domain-create-welcome-workflow"+ >+ Create the welcome email workflow+ </BigAction>+ <div className="flex flex-wrap justify-center gap-x-4 gap-y-1 text-sm">+ <Link to={urls.workflows('library')}>Pick another template</Link>+ <Link to={urls.workflows()}>Go to workflows</Link>+ </div>+ </section>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/SendingAddressCard.tsx b/products/workflows/frontend/Channels/EmailDomain/components/SendingAddressCard.tsxnew file mode 100644index 000000000000..7958c11df35a--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/SendingAddressCard.tsx@@ -0,0 +1,173 @@+import { useActions, useValues } from 'kea'++import { LemonButton, LemonInput, LemonSegmentedButton } from '@posthog/lemon-ui'++import { DEFAULT_LOCAL_PART, EmailDomainWizardLogicProps, emailDomainWizardLogic } from '../emailDomainWizardLogic'++interface SendPrefixOption {+ prefix: string+ label: string+ why: string+}++const SEND_PREFIX_OPTIONS: SendPrefixOption[] = [+ { prefix: 'mail', label: 'mail.', why: 'Keeps your main domain safe if a campaign ever lands in spam.' },+ { prefix: 'send', label: 'send.', why: 'Same protection, different name.' },+ {+ prefix: '',+ label: 'No subdomain',+ why: 'Send straight from the main domain. One bad campaign can hurt your login and support emails too.',+ },+]++const CUSTOM_PREFIX = '__custom__'+const CUSTOM_PREFIX_PLACEHOLDER = 'news'+const CUSTOM_PREFIX_WHY = 'Any name works, as long as nothing else uses it yet.'++function SendPrefixPicker(props: EmailDomainWizardLogicProps): JSX.Element {+ const logic = emailDomainWizardLogic(props)+ const { selectedDomain, sendPrefix, customPrefixOpen } = useValues(logic)+ const { setSendPrefix, setCustomPrefixOpen } = useActions(logic)+ const preset = SEND_PREFIX_OPTIONS.find((option) => option.prefix === sendPrefix)+ const custom = customPrefixOpen || !preset+ const pick = (value: string): void => {+ setCustomPrefixOpen(value === CUSTOM_PREFIX)+ setSendPrefix(value === CUSTOM_PREFIX ? CUSTOM_PREFIX_PLACEHOLDER : value)+ }+ return (+ <div className="flex flex-col gap-2">+ <span className="text-sm">Sending subdomain</span>+ <LemonSegmentedButton+ size="small"+ value={custom ? CUSTOM_PREFIX : sendPrefix}+ onChange={pick}+ options={[+ ...SEND_PREFIX_OPTIONS.map((option) => ({ value: option.prefix, label: option.label })),+ { value: CUSTOM_PREFIX, label: 'Custom' },+ ]}+ />+ {custom && (+ <div className="flex items-center gap-2 flex-wrap">+ <LemonInput+ id="email-domain-send-prefix"+ className="w-40 font-mono"+ value={sendPrefix}+ onChange={setSendPrefix}+ placeholder={CUSTOM_PREFIX_PLACEHOLDER}+ autoFocus+ />+ <span className="font-mono text-secondary break-all">.{selectedDomain}</span>+ </div>+ )}+ <span className="text-sm text-secondary">{custom ? CUSTOM_PREFIX_WHY : preset.why}</span>+ </div>+ )+}++function SenderIdentityFields(props: EmailDomainWizardLogicProps): JSX.Element {+ const logic = emailDomainWizardLogic(props)+ const { senderName, suggestedSenderName, localPart, sendingDomain } = useValues(logic)+ const { setSenderNameInput, setLocalPart } = useActions(logic)+ return (+ <div className="grid grid-cols-1 @md:grid-cols-2 gap-3">+ <div className="flex flex-col gap-1.5 text-sm">+ <label htmlFor="email-domain-sender-name-input">Name</label>+ <LemonInput+ id="email-domain-sender-name-input"+ value={senderName}+ onChange={setSenderNameInput}+ placeholder={suggestedSenderName}+ />+ <span className="text-xs text-secondary">Shown as the sender in the inbox.</span>+ </div>+ <div className="flex flex-col gap-1.5 text-sm">+ <label htmlFor="email-domain-local-part">Email address</label>+ <LemonInput+ id="email-domain-local-part"+ className="font-mono"+ value={localPart}+ onChange={setLocalPart}+ placeholder={DEFAULT_LOCAL_PART}+ suffix={<span className="font-mono text-secondary break-all">@{sendingDomain}</span>}+ />+ <span className="text-xs text-secondary">Replies go to this address unless you set another.</span>+ </div>+ </div>+ )+}++function BouncePrefixField(props: EmailDomainWizardLogicProps): JSX.Element {+ const logic = emailDomainWizardLogic(props)+ const { bouncePrefix, advancedOpen, sendingDomain, domainSender, replyTo } = useValues(logic)+ const sharedBouncePrefix = domainSender ? (domainSender.config?.mail_from_subdomain ?? 'feedback') : null+ const { setBouncePrefix, setAdvancedOpen, setReplyTo } = useActions(logic)+ if (!advancedOpen) {+ return (+ <LemonButton+ type="tertiary"+ size="xsmall"+ className="self-start"+ onClick={() => setAdvancedOpen(true)}+ data-attr="email-domain-advanced"+ >+ Advanced+ </LemonButton>+ )+ }+ return (+ <div className="flex flex-col gap-1.5 text-sm">+ <label htmlFor="email-domain-bounce-prefix">Bounce subdomain</label>+ <div className="flex items-center gap-2 flex-wrap">+ <LemonInput+ id="email-domain-bounce-prefix"+ className="w-40 font-mono"+ value={sharedBouncePrefix ?? bouncePrefix}+ onChange={setBouncePrefix}+ placeholder="feedback"+ disabledReason={+ sharedBouncePrefix !== null+ ? 'This domain already sends email, so a new address uses its bounce subdomain.'+ : undefined+ }+ />+ <span className="font-mono text-secondary break-all">.{sendingDomain}</span>+ </div>+ <span className="text-xs text-secondary">Where bounced emails return to. Almost nobody changes this.</span>+ <label htmlFor="email-domain-reply-to" className="mt-3">+ Default reply-to address <span className="text-secondary">(optional)</span>+ </label>+ <LemonInput+ id="email-domain-reply-to"+ className="max-w-80"+ value={replyTo}+ onChange={setReplyTo}+ placeholder="[email protected]"+ />+ <span className="text-xs text-secondary">+ Replies go here when an email step has no reply-to address of its own. Leave empty to send replies to+ the sender address.+ </span>+ </div>+ )+}++export function SendingAddressCard(props: EmailDomainWizardLogicProps): JSX.Element {+ const { fromAddress, senderName, suggestedSenderName } = useValues(emailDomainWizardLogic(props))+ const fromName = senderName.trim() || suggestedSenderName+ return (+ <section className="rounded-lg border bg-accent-highlight-secondary p-5 flex flex-col gap-4">+ <div className="flex flex-col gap-1">+ <span className="text-sm text-secondary">Emails will come from</span>+ <span className="text-xl @md:text-2xl font-semibold break-all">+ <span>{fromName}</span>{' '}+ <span className="font-mono">+ <<span>{fromAddress}</span>>+ </span>+ </span>+ </div>+ <SendPrefixPicker {...props} />+ <SenderIdentityFields {...props} />+ <BouncePrefixField {...props} />+ </section>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/StepHeading.tsx b/products/workflows/frontend/Channels/EmailDomain/components/StepHeading.tsxnew file mode 100644index 000000000000..3a9188233c1f--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/StepHeading.tsx@@ -0,0 +1,23 @@+import { ComponentType, ReactNode } from 'react'++import { Spinner } from '@posthog/lemon-ui'++interface StepHeadingProps {+ Hoggie: ComponentType<{ className?: string }>+ title: ReactNode+ lead?: ReactNode+ busy?: boolean+}++export function StepHeading({ Hoggie, title, lead, busy }: StepHeadingProps): JSX.Element {+ return (+ <header className="flex flex-col items-center text-center gap-4">+ <Hoggie className="w-28 @md:w-36" />+ <h1 className="m-0 text-2xl @md:text-3xl font-bold leading-tight text-balance flex items-center justify-center gap-3 flex-wrap">+ {busy && <Spinner className="text-xl" />}+ <span>{title}</span>+ </h1>+ {lead && <p className="m-0 text-base text-secondary max-w-prose text-balance">{lead}</p>}+ </header>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/StepIndicator.tsx b/products/workflows/frontend/Channels/EmailDomain/components/StepIndicator.tsxnew file mode 100644index 000000000000..c46549367a7d--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/StepIndicator.tsx@@ -0,0 +1,46 @@+import clsx from 'clsx'++import { IconCheck } from '@posthog/icons'++import { EmailDomainPhase } from '../emailDomainLogic'++const STEPS: { label: string; phases: EmailDomainPhase[] }[] = [+ { label: 'Domain', phases: ['domain'] },+ { label: 'Settings', phases: ['loading', 'unavailable', 'settings', 'verifying'] },+ { label: 'Ready', phases: ['ready'] },+]++export function StepIndicator({ phase }: { phase: EmailDomainPhase }): JSX.Element {+ const currentIndex = STEPS.findIndex((step) => step.phases.includes(phase))+ return (+ <ol className="m-0 p-0 list-none flex items-center justify-center gap-2 text-xs" aria-label="Setup steps">+ {STEPS.map((step, index) => {+ const done = index < currentIndex+ const current = index === currentIndex+ return (+ <li key={step.label} className="flex items-center gap-2">+ {index > 0 && (+ <span+ className={clsx('w-6 border-t', done || current ? 'border-accent' : 'border-primary')}+ />+ )}+ <span+ className={clsx(+ 'inline-flex items-center justify-center w-5 h-5 rounded-full border font-semibold',+ done && 'bg-success-highlight border-success text-success',+ current && 'bg-accent text-white border-accent',+ !done && !current && 'border-primary text-muted'+ )}+ aria-current={current ? 'step' : undefined}+ >+ {done ? <IconCheck /> : index + 1}+ </span>+ <span className={clsx(current ? 'font-semibold text-primary' : 'text-secondary')}>+ {step.label}+ </span>+ </li>+ )+ })}+ </ol>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/components/VerificationStepsStrip.tsx b/products/workflows/frontend/Channels/EmailDomain/components/VerificationStepsStrip.tsxnew file mode 100644index 000000000000..e15525cba1bd--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/components/VerificationStepsStrip.tsx@@ -0,0 +1,42 @@+import clsx from 'clsx'++import { IconCheck, IconWarning } from '@posthog/icons'+import { Spinner } from '@posthog/lemon-ui'++import { VerificationStep } from '../emailDomainLogic'++const STATE_ICON: Record<VerificationStep['state'], JSX.Element> = {+ done: <IconCheck className="text-success" />,+ active: <Spinner className="text-sm" />,+ todo: <span className="w-2 h-2 rounded-full border border-primary" />,+ stuck: <IconWarning className="text-danger" />,+}++export function VerificationStepsStrip({ steps }: { steps: VerificationStep[] }): JSX.Element {+ return (+ <ol className="m-0 p-0 list-none grid @md:grid-cols-3 gap-2 text-sm" aria-label="Verification steps">+ {steps.map((step) => (+ <li+ key={step.key}+ className={clsx(+ 'flex items-start gap-2 rounded border p-2.5 min-w-0',+ step.state === 'done' && 'bg-success-highlight border-success',+ step.state === 'active' && 'bg-accent-highlight-secondary border-accent',+ step.state === 'stuck' && 'bg-danger-highlight border-danger',+ step.state === 'todo' && 'bg-surface-secondary'+ )}+ >+ <span className="shrink-0 w-5 h-5 inline-flex items-center justify-center">+ {STATE_ICON[step.state]}+ </span>+ <span className="flex flex-col min-w-0">+ <span className={clsx('font-medium', step.state === 'todo' && 'text-secondary')}>+ {step.label}+ </span>+ <span className="text-xs text-secondary">{step.detail}</span>+ </span>+ </li>+ ))}+ </ol>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/dnsHosts.ts b/products/workflows/frontend/Channels/EmailDomain/dnsHosts.tsindex cc3a770f73d2..7b030ce0df58 100644--- a/products/workflows/frontend/Channels/EmailDomain/dnsHosts.ts+++ b/products/workflows/frontend/Channels/EmailDomain/dnsHosts.ts@@ -2,10 +2,10 @@ const DNS_HOST_GOTCHAS: Record<string, string> = {Cloudflare: 'Keep the proxy off (grey cloud) on the CNAME records. Proxied CNAMEs do not work for DKIM.','Route 53': 'Route 53 asks for the full record name. Paste the name as shown, including your domain.',Namecheap:- 'Namecheap adds your domain to the Host field. Paste only the part before your domain, so "feedback" and not "feedback.acme.com".',+ 'Namecheap adds your root domain to the Host field. Paste the name without it, so "feedback.mail" for feedback.mail.acme.com.',}const GENERIC_GOTCHA =- 'If the name field already ends with your domain, paste only the part before it. Otherwise paste the full name.'+ 'If the name field already ends with your root domain, like acme.com, paste only the part before it. Otherwise paste the full name.'export const dnsHostGotcha = (hostName: string | null): string => DNS_HOST_GOTCHAS[hostName ?? ''] ?? GENERIC_GOTCHAdiff --git a/products/workflows/frontend/Channels/EmailDomain/emailDomainRoutes.test.ts b/products/workflows/frontend/Channels/EmailDomain/emailDomainRoutes.test.tsnew file mode 100644index 000000000000..37173ebb4b67--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/emailDomainRoutes.test.ts@@ -0,0 +1,46 @@+import { kea, path } from 'kea'+import { router, urlToAction } from 'kea-router'++import { productRoutes } from '~/products'+import { initKeaTests } from '~/test/init'++describe('email domain routes', () => {+ // The sending domain page sits under /workflows/channels/email, next to the '/workflows/:id/:tab'+ // workflow route. kea-router takes the first match, so the page must never resolve as a workflow.+ let resolvedScene: string | null = null++ const routeLogic = kea([+ path(['products', 'workflows', 'frontend', 'Channels', 'EmailDomain', 'emailDomainRoutesTest']),+ urlToAction(() =>+ Object.fromEntries(+ Object.entries(productRoutes)+ .filter(([route]) => route.startsWith('/workflows'))+ .map(([route, [scene]]) => [+ route,+ () => {+ resolvedScene = scene+ },+ ])+ )+ ),+ ])++ beforeEach(() => {+ resolvedScene = null+ initKeaTests(false)+ routeLogic.mount()+ })++ afterEach(() => routeLogic.unmount())++ it.each([+ ['/workflows/channels/email/new', 'WorkflowsEmailDomain'],+ ['/workflows/channels/email/42', 'WorkflowsEmailDomain'],+ ['/workflows/channels', 'Workflows'],+ ['/workflows/01a05e5e-38c2-0000-b81a-21fe48581914/workflow', 'Workflow'],+ ])('opens %s in the %s scene', (url, scene) => {+ router.actions.push(url)++ expect(resolvedScene).toBe(scene)+ })+})diff --git a/products/workflows/frontend/Channels/EmailDomain/hoggies.ts b/products/workflows/frontend/Channels/EmailDomain/hoggies.tsnew file mode 100644index 000000000000..7f6f700429f6--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/hoggies.ts@@ -0,0 +1,19 @@+import * as cowboyLassoPng from '@posthog/brand/hoggies/png/cowboy-lasso'+import * as hourglassPng from '@posthog/brand/hoggies/png/hourglass'+import * as magnifyingGlassPng from '@posthog/brand/hoggies/png/magnifying-glass'+import * as mailboxPng from '@posthog/brand/hoggies/png/mailbox'+import * as panicPng from '@posthog/brand/hoggies/png/panic'+import * as robotPng from '@posthog/brand/hoggies/png/robot'+import * as rocketPng from '@posthog/brand/hoggies/png/rocket'+import * as wizardPng from '@posthog/brand/hoggies/png/wizard-1'++import { pngHoggie } from 'lib/brand/hoggies'++export const HedgehogCowboyLasso = pngHoggie(cowboyLassoPng)+export const HedgehogHourglass = pngHoggie(hourglassPng)+export const HedgehogMagnifyingGlass = pngHoggie(magnifyingGlassPng)+export const HedgehogMailbox = pngHoggie(mailboxPng)+export const HedgehogPanic = pngHoggie(panicPng)+export const HedgehogRobot = pngHoggie(robotPng)+export const HedgehogRocket = pngHoggie(rocketPng)+export const HedgehogWizard = pngHoggie(wizardPng)diff --git a/products/workflows/frontend/Channels/EmailDomain/steps/DomainStep.tsx b/products/workflows/frontend/Channels/EmailDomain/steps/DomainStep.tsxnew file mode 100644index 000000000000..74964b48c508--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/steps/DomainStep.tsx@@ -0,0 +1,105 @@+import { useActions, useValues } from 'kea'++import { IconArrowRight } from '@posthog/icons'+import { LemonButton, LemonSkeleton, Link } from '@posthog/lemon-ui'++import { urls } from 'scenes/urls'++import { AnotherDomainInput } from '../components/AnotherDomainInput'+import { BigAction } from '../components/BigAction'+import { DomainCard } from '../components/DomainCard'+import { LocalProviderPicker } from '../components/LocalProviderPicker'+import { SendingAddressCard } from '../components/SendingAddressCard'+import { StepHeading } from '../components/StepHeading'+import { EmailDomainWizardLogicProps, emailDomainWizardLogic } from '../emailDomainWizardLogic'+import { HedgehogMailbox } from '../hoggies'++function DomainChoices(props: EmailDomainWizardLogicProps): JSX.Element {+ const logic = emailDomainWizardLogic(props)+ const { inferredDomains, eventHostsLoading, selectedDomain, selectedIsInferred } = useValues(logic)+ const { selectDomain, clearDomain } = useActions(logic)+ return (+ <div className="flex flex-col gap-3">+ {eventHostsLoading && inferredDomains.length === 0 && <LemonSkeleton className="h-20" />}+ {inferredDomains.map((candidate) => (+ <DomainCard+ key={candidate.domain}+ {...candidate}+ selected={selectedDomain === candidate.domain}+ onSelect={() => selectDomain(candidate.domain)}+ />+ ))}+ {selectedDomain && !selectedIsInferred && (+ <DomainCard+ domain={selectedDomain}+ reasons={['You typed this one']}+ recommended={false}+ selected+ onSelect={clearDomain}+ />+ )}+ </div>+ )+}++function CreateSender(props: EmailDomainWizardLogicProps): JSX.Element {+ const logic = emailDomainWizardLogic(props)+ const { existingSender, submitError, createdSenderLoading, bouncePrefix, domainSender } = useValues(logic)+ const { clearDomain, createSender } = useActions(logic)+ const disabledReason = createdSenderLoading+ ? 'Creating the sender'+ : existingSender+ ? 'A sender with this address already exists'+ : !bouncePrefix && !domainSender+ ? 'Type a bounce subdomain'+ : undefined+ return (+ <>+ {existingSender && (+ <p className="m-0 text-sm text-center text-secondary">+ A sender with this address already exists in this project.{' '}+ <Link to={urls.workflowsEmailDomain(existingSender.id)}>Open it</Link> to check its status.+ </p>+ )}+ {submitError && <p className="m-0 text-sm text-center text-danger">{submitError}</p>}+ <div className="flex flex-col items-center gap-2">+ <BigAction+ onClick={createSender}+ sideIcon={<IconArrowRight />}+ loading={createdSenderLoading}+ disabledReason={disabledReason}+ data-attr="email-domain-continue"+ >+ Continue+ </BigAction>+ <LemonButton type="tertiary" size="small" onClick={clearDomain}>+ Another domain+ </LemonButton>+ </div>+ </>+ )+}++export function DomainStep(props: EmailDomainWizardLogicProps): JSX.Element {+ const { inferredDomains, eventHostsLoading, selectedDomain } = useValues(emailDomainWizardLogic(props))+ const lead =+ eventHostsLoading || inferredDomains.length > 0+ ? 'We looked at your project and found these. Pick one or type your own.'+ : 'Type the domain your emails should come from.'++ return (+ <div className="flex flex-col gap-8">+ <StepHeading Hoggie={HedgehogMailbox} title="Which domain should your emails come from?" lead={lead} />+ <DomainChoices {...props} />+ {selectedDomain ? (+ <>+ <SendingAddressCard {...props} />+ <LocalProviderPicker {...props} />+ <CreateSender {...props} />+ </>+ ) : (+ <AnotherDomainInput {...props} />+ )}+ </div>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/steps/ReadyStep.tsx b/products/workflows/frontend/Channels/EmailDomain/steps/ReadyStep.tsxnew file mode 100644index 000000000000..b5d043209378--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/steps/ReadyStep.tsx@@ -0,0 +1,70 @@+import { useValues } from 'kea'++import { IconCheck, IconWarning } from '@posthog/icons'+import { LemonCollapse } from '@posthog/lemon-ui'++import { DnsRecordRows } from '../components/DnsRecordRows'+import { FirstSenderCard } from '../components/FirstSenderCard'+import { NextWorkflowCard } from '../components/NextWorkflowCard'+import { StepHeading } from '../components/StepHeading'+import { emailDomainAutoConfigureLogic } from '../emailDomainAutoConfigureLogic'+import { emailDomainSenderLogic } from '../emailDomainSenderLogic'+import { emailDomainStatusLogic } from '../emailDomainStatusLogic'+import { HedgehogRocket } from '../hoggies'++export function ReadyStep(): JSX.Element {+ const { domain } = useValues(emailDomainSenderLogic)+ const { records, foundCount, allRecordsFound } = useValues(emailDomainStatusLogic)+ const { hostName } = useValues(emailDomainAutoConfigureLogic)+ const host = hostName ?? 'your DNS host'+ return (+ <div className="flex flex-col gap-8">+ <div className="rounded-xl border border-success bg-success-highlight p-6 @md:p-8">+ <StepHeading+ Hoggie={HedgehogRocket}+ title={+ <>+ You can send from <span className="font-mono break-all">{domain}</span>+ </>+ }+ lead={+ allRecordsFound+ ? `All ${records.length} settings are in place. Inboxes now know these emails really come from you.`+ : `The email provider verified this domain. ${foundCount} of ${records.length} settings are in place, so add the rest at ${host}.`+ }+ />+ </div>+ <FirstSenderCard />+ <LemonCollapse+ defaultActiveKey={allRecordsFound ? undefined : 'records'}+ panels={[+ {+ key: 'records',+ header: (+ <span className="flex items-center gap-2">+ {allRecordsFound ? (+ <IconCheck className="text-success" />+ ) : (+ <IconWarning className="text-warning" />+ )}+ <span>+ {allRecordsFound+ ? `${records.length} settings in place at ${host}`+ : `${foundCount} of ${records.length} settings in place at ${host}`}+ </span>+ </span>+ ),+ content: (+ <DnsRecordRows+ records={records}+ missing={records.filter((record) => record.status === 'pending')}+ showStatus+ />+ ),+ },+ ]}+ />+ <NextWorkflowCard />+ </div>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/steps/SettingsStep.tsx b/products/workflows/frontend/Channels/EmailDomain/steps/SettingsStep.tsxnew file mode 100644index 000000000000..adbcee9c5194--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/steps/SettingsStep.tsx@@ -0,0 +1,179 @@+import { useActions, useValues } from 'kea'++import { IconRefresh } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { AgentSetupButton } from '../components/AgentSetupButton'+import { BigAction } from '../components/BigAction'+import { DnsHostLink } from '../components/DnsHostLink'+import { DnsRecordRows } from '../components/DnsRecordRows'+import { StepHeading } from '../components/StepHeading'+import { VerificationStepsStrip } from '../components/VerificationStepsStrip'+import { dnsHostGotcha } from '../dnsHosts'+import { emailDomainAutoConfigureLogic } from '../emailDomainAutoConfigureLogic'+import { emailDomainLogic } from '../emailDomainLogic'+import { emailDomainManualSetupLogic } from '../emailDomainManualSetupLogic'+import { emailDomainSenderLogic } from '../emailDomainSenderLogic'+import { emailDomainStatusLogic } from '../emailDomainStatusLogic'+import { HedgehogMagnifyingGlass, HedgehogWizard } from '../hoggies'++const RECORDS_EXPLAINER =+ 'Each setting is a DNS record. Add them exactly as shown, name and value, and keep the rest of your DNS as it is.'++function Gotcha(): JSX.Element {+ const { hostName } = useValues(emailDomainAutoConfigureLogic)+ return <p className="m-0 text-sm text-secondary text-center text-balance">Heads up: {dnsHostGotcha(hostName)}</p>+}++function AddedThemButton({ primary }: { primary?: boolean }): JSX.Element {+ const { rechecking } = useValues(emailDomainStatusLogic)+ const { markRecordsAdded } = useActions(emailDomainManualSetupLogic)+ const Button = primary ? BigAction : LemonButton+ return (+ <Button+ type={primary ? 'primary' : 'secondary'}+ onClick={markRecordsAdded}+ loading={rechecking}+ disabledReason={rechecking ? 'Checking' : undefined}+ data-attr="email-domain-records-added"+ >+ I've added them+ </Button>+ )+}++function AutoConfigureChoice(): JSX.Element {+ const { hostName, autoConfigureLoading } = useValues(emailDomainAutoConfigureLogic)+ const { openAutoConfigure } = useActions(emailDomainAutoConfigureLogic)+ const { recordsRevealed } = useValues(emailDomainManualSetupLogic)+ const { revealRecords } = useActions(emailDomainManualSetupLogic)+ const { records } = useValues(emailDomainStatusLogic)+ return (+ <div className="flex flex-col gap-6">+ <div className="flex flex-col items-center gap-2">+ <BigAction+ onClick={openAutoConfigure}+ loading={autoConfigureLoading}+ disabledReason={autoConfigureLoading ? 'Opening' : undefined}+ data-attr="email-domain-auto-configure"+ >+ Add them to {hostName} for me+ </BigAction>+ <span className="text-xs text-secondary">You approve it once in {hostName}. Nothing else changes.</span>+ <div className="flex flex-wrap justify-center gap-1">+ {!recordsRevealed && (+ <LemonButton type="tertiary" onClick={revealRecords} data-attr="email-domain-reveal-records">+ I'll add them myself+ </LemonButton>+ )}+ <AgentSetupButton />+ </div>+ </div>+ {recordsRevealed && (+ <div className="flex flex-col gap-3">+ <p className="m-0 text-sm text-secondary text-center">{RECORDS_EXPLAINER}</p>+ <DnsRecordRows records={records} showStatus />+ <Gotcha />+ <div className="flex flex-wrap justify-center gap-1">+ <DnsHostLink />+ <AddedThemButton />+ </div>+ </div>+ )}+ </div>+ )+}++function ManualChoice(): JSX.Element {+ const { dnsHost } = useValues(emailDomainAutoConfigureLogic)+ const { records } = useValues(emailDomainStatusLogic)+ return (+ <div className="flex flex-col gap-5">+ <div className="flex flex-col items-center gap-2">+ {dnsHost ? (+ <>+ <DnsHostLink primary />+ <AddedThemButton />+ </>+ ) : (+ <AddedThemButton primary />+ )}+ <AgentSetupButton />+ </div>+ <Gotcha />+ <p className="m-0 text-sm text-secondary text-center">{RECORDS_EXPLAINER}</p>+ <DnsRecordRows records={records} showStatus />+ </div>+ )+}++function NoRecordsYet(): JSX.Element {+ const { restartResultLoading } = useValues(emailDomainStatusLogic)+ const { restartVerification } = useActions(emailDomainStatusLogic)+ return (+ <div className="flex flex-col items-center gap-2">+ <p className="m-0 text-sm text-secondary text-center">+ The email provider has not handed out your settings yet. Start verification to get them.+ </p>+ <BigAction+ icon={<IconRefresh />}+ onClick={restartVerification}+ loading={restartResultLoading}+ disabledReason={restartResultLoading ? 'Starting' : undefined}+ data-attr="email-domain-start-verification"+ >+ Start verification+ </BigAction>+ </div>+ )+}++function FindingHost({ domain, count }: { domain: string | null; count: number }): JSX.Element {+ return (+ <div className="flex flex-col gap-8">+ <StepHeading+ Hoggie={HedgehogMagnifyingGlass}+ busy+ title={`Finding where ${domain}'s DNS lives…`}+ lead="This tells us whether we can add the settings for you."+ />+ <BigAction disabledReason="Still finding your DNS host">+ {count ? `Add ${count} settings` : 'Get your settings'}+ </BigAction>+ </div>+ )+}++export function SettingsStep(): JSX.Element {+ const { domain } = useValues(emailDomainSenderLogic)+ const { detectionLoading, hostName, supportsDomainConnect } = useValues(emailDomainAutoConfigureLogic)+ const { records } = useValues(emailDomainStatusLogic)+ const { verificationSteps } = useValues(emailDomainLogic)+ const count = records.length+ const host = hostName ?? 'your DNS host'++ if (detectionLoading) {+ return <FindingHost domain={domain} count={count} />+ }++ const lead = supportsDomainConnect+ ? `${hostName} runs ${domain}'s DNS and lets PostHog add settings for you.`+ : hostName+ ? `${hostName} runs ${domain}'s DNS. Add these there, then come back.`+ : `We could not tell who runs ${domain}'s DNS. Open your DNS provider's settings and add these.`++ return (+ <div className="flex flex-col gap-8">+ <StepHeading+ Hoggie={HedgehogWizard}+ title={count ? `Add ${count} settings at ${host}` : 'Get your settings from the email provider'}+ lead={lead}+ />+ {count === 0 ? <NoRecordsYet /> : supportsDomainConnect ? <AutoConfigureChoice /> : <ManualChoice />}+ <div className="flex flex-col gap-2">+ <span className="text-xs text-secondary text-center uppercase tracking-wide">What happens next</span>+ <VerificationStepsStrip steps={verificationSteps} />+ </div>+ </div>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/steps/UnavailableStep.tsx b/products/workflows/frontend/Channels/EmailDomain/steps/UnavailableStep.tsxnew file mode 100644index 000000000000..f0bdd20814b8--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/steps/UnavailableStep.tsx@@ -0,0 +1,32 @@+import { useActions, useValues } from 'kea'++import { IconRefresh } from '@posthog/icons'++import { BigAction } from '../components/BigAction'+import { StepHeading } from '../components/StepHeading'+import { emailDomainLogic } from '../emailDomainLogic'+import { HedgehogPanic } from '../hoggies'++export function UnavailableStep(): JSX.Element {+ const { senderLoading, statusLoading } = useValues(emailDomainLogic)+ const { retry } = useActions(emailDomainLogic)+ const retrying = senderLoading || statusLoading+ return (+ <div className="flex flex-col gap-8">+ <StepHeading+ Hoggie={HedgehogPanic}+ title="We could not load your sending domain"+ lead="Something went wrong while checking it. Try again, and if it keeps happening contact support."+ />+ <BigAction+ icon={<IconRefresh />}+ onClick={retry}+ loading={retrying}+ disabledReason={retrying ? 'Loading' : undefined}+ data-attr="email-domain-retry"+ >+ Try again+ </BigAction>+ </div>+ )+}diff --git a/products/workflows/frontend/Channels/EmailDomain/steps/VerifyingStep.tsx b/products/workflows/frontend/Channels/EmailDomain/steps/VerifyingStep.tsxnew file mode 100644index 000000000000..a9d83c9ef967--- /dev/null+++ b/products/workflows/frontend/Channels/EmailDomain/steps/VerifyingStep.tsx@@ -0,0 +1,169 @@+import { useActions, useValues } from 'kea'++import { IconRefresh } from '@posthog/icons'+import { LemonBanner } from '@posthog/lemon-ui'++import { LemonProgress } from 'lib/lemon-ui/LemonProgress'++import { AgentSetupButton } from '../components/AgentSetupButton'+import { BigAction } from '../components/BigAction'+import { DnsHostLink } from '../components/DnsHostLink'+import { DnsRecordRows, RECORD_KIND_LABEL } from '../components/DnsRecordRows'+import { StepHeading } from '../components/StepHeading'+import { VerificationStepsStrip } from '../components/VerificationStepsStrip'+import { emailDomainAutoConfigureLogic } from '../emailDomainAutoConfigureLogic'+import { emailDomainLogic } from '../emailDomainLogic'+import { emailDomainManualSetupLogic } from '../emailDomainManualSetupLogic'+import { emailDomainStatusLogic } from '../emailDomainStatusLogic'+import { HedgehogHourglass, HedgehogPanic } from '../hoggies'++function Heading(): JSX.Element {+ const { status, pollingStopped, missingRecords, foundCount, records, allRecordsFound } =+ useValues(emailDomainStatusLogic)+ const { hostName } = useValues(emailDomainAutoConfigureLogic)+ const { recordsAdded } = useValues(emailDomainManualSetupLogic)+ const host = hostName ?? 'your DNS host'+ if (status?.status === 'failed') {+ return (+ <StepHeading+ Hoggie={HedgehogPanic}+ title="Verification stopped"+ lead="The email provider gave up waiting for the settings. Check them once more, then restart verification."+ />+ )+ }+ if (pollingStopped && allRecordsFound && status?.status !== 'temporary_failure') {+ return (+ <StepHeading+ Hoggie={HedgehogHourglass}+ title="Your records are in place"+ lead="The email provider is still confirming them. This can take up to 72 hours. Check again to ask it now."+ />+ )+ }+ if (pollingStopped && allRecordsFound) {+ return (+ <StepHeading+ Hoggie={HedgehogPanic}+ title="The email provider can't confirm your records yet"+ lead={`Every record is in place at ${host}, but the provider reported a temporary problem. Check again in a few minutes.`}+ />+ )+ }+ if (pollingStopped) {+ const missing = missingRecords.length+ return (+ <StepHeading+ Hoggie={HedgehogPanic}+ title={missing === 1 ? 'One setting is still missing' : `${missing} settings are still missing`}+ lead={`We found ${foundCount} of ${records.length}. Check the highlighted ones at ${host}, then check again.`}+ />+ )+ }+ return (+ <StepHeading+ Hoggie={HedgehogHourglass}+ busy+ title="Checking your settings…"+ lead={+ recordsAdded+ ? 'DNS changes can take a few minutes to show up. You can leave this page and come back.'+ : 'Some settings are already in place. We keep checking while this page is open.'+ }+ />+ )+}++function SecondaryActions(): JSX.Element {+ return (+ <div className="flex flex-wrap justify-center gap-1">+ <AgentSetupButton />+ <DnsHostLink />+ </div>+ )+}++function Actions(): JSX.Element {+ const { status, pollingStopped, allRecordsFound, rechecking, restartResultLoading } =+ useValues(emailDomainStatusLogic)+ const { checkAgain, restartVerification } = useActions(emailDomainStatusLogic)+ if (status?.status === 'failed') {+ return (+ <div className="flex flex-col items-center gap-2">+ <BigAction+ icon={<IconRefresh />}+ onClick={restartVerification}+ loading={restartResultLoading}+ disabledReason={restartResultLoading ? 'Restarting' : undefined}+ data-attr="email-domain-restart-verification"+ >+ Restart verification+ </BigAction>+ <SecondaryActions />+ </div>+ )+ }+ if (pollingStopped) {+ return (+ <div className="flex flex-col items-center gap-2">+ {!allRecordsFound && (+ <LemonBanner type="warning" className="w-full">+ Still waiting on DNS. We stopped checking automatically, so check again once you have added the+ missing settings.+ </LemonBanner>+ )}+ <BigAction+ icon={<IconRefresh />}+ onClick={checkAgain}+ loading={rechecking || restartResultLoading}+ disabledReason={rechecking || restartResultLoading ? 'Checking' : undefined}+ data-attr="email-domain-check-again"+ >+ Check again+ </BigAction>+ <SecondaryActions />+ </div>+ )+ }+ return <SecondaryActions />+}++export function VerifyingStep(): JSX.Element {+ const { status, pollingStopped, missingRecords, foundCount, records, allRecordsFound } =+ useValues(emailDomainStatusLogic)+ const { verificationSteps } = useValues(emailDomainLogic)+ const stuck = (pollingStopped && !allRecordsFound) || status?.status === 'failed'+ const temporaryFailure = status?.status === 'temporary_failure'+ return (+ <div className="flex flex-col gap-8">+ <Heading />+ <div className="flex flex-col gap-2">+ <LemonProgress+ percent={records.length ? (foundCount / records.length) * 100 : 0}+ size="large"+ strokeColor={stuck ? 'var(--danger)' : 'var(--success)'}+ bgColor="var(--border-primary)"+ />+ <span className="text-sm text-secondary text-center">{`${foundCount} of ${records.length} found`}</span>+ </div>+ <VerificationStepsStrip steps={verificationSteps} />+ {temporaryFailure && (+ <LemonBanner type="error">+ {allRecordsFound ? (+ <span>+ Every setting is in place at your DNS host, but the email provider reported a temporary+ problem confirming them.+ </span>+ ) : (+ <span>{`The email provider could not find these settings: ${+ missingRecords.map((record) => RECORD_KIND_LABEL[record.kind]).join(', ') || 'some of them'+ }. Check them at your DNS host.`}</span>+ )}+ {!pollingStopped && <span> We keep checking.</span>}+ </LemonBanner>+ )}+ <Actions />+ <DnsRecordRows records={records} missing={missingRecords} showStatus />+ </div>+ )+}diff --git a/products/workflows/manifest.tsx b/products/workflows/manifest.tsxindex 23941e27bd29..7685fdf87c01 100644--- a/products/workflows/manifest.tsx+++ b/products/workflows/manifest.tsx@@ -43,11 +43,18 @@ export const manifest: ProductManifest = {projectBased: true,description: 'Send a one-time or scheduled email to a group of people',},+ WorkflowsEmailDomain: {+ import: () => import('./frontend/Channels/EmailDomain/EmailDomainScene'),+ name: 'Workflows',+ iconType: 'workflows',+ projectBased: true,+ },},routes: {// URL: [Scene, SceneKey]'/workflows': ['Workflows', 'workflows'],'/workflows/:tab': ['Workflows', 'workflows'],+ '/workflows/channels/email/:id': ['WorkflowsEmailDomain', 'workflowsEmailDomain'],'/workflows/:id/:tab': ['Workflow', 'workflowTab'],'/workflows/library/templates/:id': ['WorkflowsLibraryTemplate', 'workflowsLibraryTemplate'],'/workflows/library/templates/new': ['WorkflowsLibraryTemplate', 'workflowsLibraryTemplate'],