: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
fix(workflows): keep the email sender modal open when config lacks email (#93092)
posthog[bot]8dadebd3cd2d
diff --git a/products/workflows/frontend/Channels/EmailSetup/emailSetupModalLogic.test.ts b/products/workflows/frontend/Channels/EmailSetup/emailSetupModalLogic.test.tsnew file mode 100644index 000000000000..524ebf63c4f5--- /dev/null+++ b/products/workflows/frontend/Channels/EmailSetup/emailSetupModalLogic.test.ts@@ -0,0 +1,36 @@+import { expectLogic } from 'kea-test-utils'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'+import { IntegrationType } from '~/types'++import { emailSetupModalLogic } from './emailSetupModalLogic'++describe('emailSetupModalLogic', () => {+ beforeEach(() => {+ useMocks({+ get: { '/api/environments/:team_id/integrations': { results: [] } },+ post: {+ '/api/environments/:team_id/integrations/:id/email/verify': { status: 'pending', dnsRecords: [] },+ },+ })+ initKeaTests()+ })++ // A legacy or hand-edited integration row can hold a config without an `email` key. An unguarded+ // read of it threw, and the error escaped to the app error boundary, so the whole scene went+ // blank instead of the modal opening.+ it('keeps the form defaults when the integration config has no email', async () => {+ const logic = emailSetupModalLogic({+ integration: { id: 1, kind: 'email', config: {} } as IntegrationType,+ onComplete: () => {},+ onClose: () => {},+ })+ logic.mount()++ await expectLogic(logic).toMatchValues({+ domain: '',+ emailSender: expect.objectContaining({ email: '', name: '', provider: 'ses' }),+ })+ })+})diff --git a/products/workflows/frontend/Channels/EmailSetup/emailSetupModalLogic.ts b/products/workflows/frontend/Channels/EmailSetup/emailSetupModalLogic.tsindex d0e3a4f85324..cd2f3a354e1e 100644--- a/products/workflows/frontend/Channels/EmailSetup/emailSetupModalLogic.ts+++ b/products/workflows/frontend/Channels/EmailSetup/emailSetupModalLogic.ts@@ -55,10 +55,11 @@ export const parseHostname = (hostname: string, rootDomain: string): { subdomainconst getEmailSenderFromIntegration = (integration: IntegrationType): EmailSenderFormType => {return {- email: integration.config.email,- name: integration.config.name,- provider: integration.config.provider,- mail_from_subdomain: integration.config.mail_from_subdomain,+ // `config` is untyped, so a legacy or hand-edited row can miss keys. Keep the form defaults instead.+ email: integration.config?.email ?? '',+ name: integration.config?.name ?? '',+ provider: integration.config?.provider ?? 'ses',+ mail_from_subdomain: integration.config?.mail_from_subdomain,}}@@ -268,7 +269,7 @@ export const emailSetupModalLogic = kea<emailSetupModalLogicType>([domain: [(s) => [s.emailSender],(emailSender: EmailSenderFormType): string => {- return emailSender.email.includes('@') ? emailSender.email.split('@')[1] : ''+ return emailSender.email?.includes('@') ? emailSender.email.split('@')[1] : ''},],isDomainVerified: [