: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
chore(messaging): drop vestigial from.email and from.name in native email (#60438)
Daniel Marchuk94f26191a77d
diff --git a/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsx b/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsxindex 1320a1b4577b..fc735b9e07de 100644--- a/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsx+++ b/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsx@@ -232,12 +232,7 @@ function NativeEmailIntegrationChoice({window.open(urls.workflows('channels'), '_blank')return}- const integration = integrationsOfKind?.find((x) => x.id === integrationId)- onChange({- integrationId,- email: integration?.config?.email_address ?? '[email protected]', // TODO: Remove this default later- // name: integration?.config?.name, // TODO: Add support for the name?- })+ onChange({ integrationId })}if (!integrationsLoading && integrationsOfKind?.length === 0) {diff --git a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.tsindex 32511598ff56..f334cc510f19 100644--- a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts+++ b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts@@ -1663,10 +1663,7 @@ describe('Hogflow Executor', () => {email: '',name: '',},- from: {- email: '',- name: '',- },+ from: {},replyTo: '',subject: '',preheader: '',@@ -1714,7 +1711,6 @@ describe('Hogflow Executor', () => {},from: {integrationId: 1,- email: '[email protected]',},subject: 'Test Email 1',text: 'Test Text 1',@@ -1737,7 +1733,6 @@ describe('Hogflow Executor', () => {},from: {integrationId: 1,- email: '[email protected]',},subject: 'Test Email 2',text: 'Test Text 2',diff --git a/nodejs/src/cdp/services/messaging/email.service.test.ts b/nodejs/src/cdp/services/messaging/email.service.test.tsindex 06a32a8f28f7..e5d3c4aa4c1b 100644--- a/nodejs/src/cdp/services/messaging/email.service.test.ts+++ b/nodejs/src/cdp/services/messaging/email.service.test.ts@@ -57,7 +57,7 @@ const createEmailParams = (return {type: 'email',to: { email: '[email protected]', name: 'Test User' },- from: { email: '[email protected]', name: 'Test User', integrationId: 1 },+ from: { integrationId: 1 },subject: 'Test Subject',text: 'Test Text',html: 'Test HTML',@@ -112,7 +112,7 @@ describe('EmailService', () => {const invocation = createExampleInvocation({ team_id: team.id, id: 'function-1' })invocation.id = 'invocation-1'invocation.state.vmState = { stack: [] } as any- invocation.queueParameters = createEmailParams({ from: { integrationId: 1, email: '[email protected]' } })+ invocation.queueParameters = createEmailParams({ from: { integrationId: 1 } })const result = await serviceWithoutSES.executeSendEmail(invocation)expect(result.error).toBe('SES is not configured - set SES_REGION and AWS credentials')@@ -139,7 +139,7 @@ describe('EmailService', () => {invocation.state.vmState = {stack: [],} as any- invocation.queueParameters = createEmailParams({ from: { integrationId: 1, email: '[email protected]' } })+ invocation.queueParameters = createEmailParams({ from: { integrationId: 1 } })// Mock SES v2 send to avoid actual AWS callssendEmailSpy = jest.spyOn(service.sesV2Client!, 'send') as any@@ -165,14 +165,14 @@ describe('EmailService', () => {})it('should validate if the integration is not found', async () => {invocation.queueParameters = createEmailParams({- from: { integrationId: 100, email: '[email protected]' },+ from: { integrationId: 100 },})const result = await service.executeSendEmail(invocation)expect(result.error).toMatchInlineSnapshot(`"Email integration not found"`)})it('should validate if the integration is not an email integration', async () => {invocation.queueParameters = createEmailParams({- from: { integrationId: 3, email: '[email protected]' },+ from: { integrationId: 3 },})const result = await service.executeSendEmail(invocation)expect(result.error).toMatchInlineSnapshot(`"Email integration not found"`)@@ -180,24 +180,14 @@ describe('EmailService', () => {it('should validate if the integration is not the correct team', async () => {invocation.teamId = 100invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },})const result = await service.executeSendEmail(invocation)expect(result.error).toMatchInlineSnapshot(`"Email integration not found"`)})- it('should ignore a given email and use the integration config', async () => {- invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]', name: '' },- })- const result = await service.executeSendEmail(invocation)- expect(result.error).toBeUndefined()- expect(sendEmailSpy).toHaveBeenCalled()- const sentCommand = sendEmailSpy.mock.calls[0][0] as { input: any }- expect(sentCommand.input.FromEmailAddress).toBe('"Test User" <[email protected]>')- })it('should validate if the email domain is not verified', async () => {invocation.queueParameters = createEmailParams({- from: { integrationId: 2, email: '[email protected]', name: '' },+ from: { integrationId: 2 },})const result = await service.executeSendEmail(invocation)expect(result.error).toMatchInlineSnapshot(`"The selected email integration domain is not verified"`)@@ -205,7 +195,7 @@ describe('EmailService', () => {it('should send identical from and feedback forwarding args', async () => {// This test is important for spam classification - feedback forwarding email MUST match from emailinvocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },})const result = await service.executeSendEmail(invocation)expect(result.error).toBeUndefined()@@ -216,7 +206,7 @@ describe('EmailService', () => {})it('should allow a valid email integration and domain', async () => {invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },})const result = await service.executeSendEmail(invocation)expect(result.error).toBeUndefined()@@ -274,7 +264,7 @@ describe('EmailService', () => {invocation.state.vmState = {stack: [],} as any- invocation.queueParameters = createEmailParams({ from: { integrationId: 1, email: '[email protected]' } })+ invocation.queueParameters = createEmailParams({ from: { integrationId: 1 } })await mailDevAPI.clearEmails()})it('should send an email', async () => {@@ -329,7 +319,7 @@ describe('EmailService', () => {stack: [],} as anyinvocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },})sendEmailSpy = jest.spyOn(service.sesV2Client!, 'send')})@@ -390,7 +380,7 @@ describe('EmailService', () => {it('should include cc addresses in SES destination', async () => {sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },cc: '[email protected], [email protected]',})const result = await service.executeSendEmail(invocation)@@ -402,7 +392,7 @@ describe('EmailService', () => {it('should include bcc addresses in SES destination', async () => {sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },bcc: '[email protected]',})const result = await service.executeSendEmail(invocation)@@ -414,7 +404,7 @@ describe('EmailService', () => {it('should not include cc/bcc in SES destination when not provided', async () => {sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },})const result = await service.executeSendEmail(invocation)expect(result.error).toBeUndefined()@@ -426,7 +416,7 @@ describe('EmailService', () => {it('should not include cc/bcc in SES destination when empty strings', async () => {sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },cc: '',bcc: ' ',})@@ -440,7 +430,7 @@ describe('EmailService', () => {it('should not include replyTo if not in params', async () => {sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },})const result = await service.executeSendEmail(invocation)expect(result.error).toBeUndefined()@@ -451,7 +441,7 @@ describe('EmailService', () => {it('should include single replyTo address if in params', async () => {sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },replyTo: 'Customer Service <[email protected]>',})const result = await service.executeSendEmail(invocation)@@ -463,7 +453,7 @@ describe('EmailService', () => {it('should split multiple comma-separated replyTo addresses', async () => {sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },})const result = await service.executeSendEmail(invocation)@@ -480,7 +470,7 @@ describe('EmailService', () => {sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })invocation.hogFunction.metadata = { message_category_type: 'transactional' }invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },html: '',text: 'Hello, this is a plain text email.',})@@ -497,7 +487,7 @@ describe('EmailService', () => {it('should not include preheader span if not in params', async () => {sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },html: '<tbody>Test email content</tbody>',})const result = await service.executeSendEmail(invocation)@@ -510,7 +500,7 @@ describe('EmailService', () => {it('should include preheader at top of HTML if in params', async () => {sendEmailSpy.mockResolvedValue({ MessageId: 'test-message-id' })invocation.queueParameters = createEmailParams({- from: { integrationId: 1, email: '[email protected]' },+ from: { integrationId: 1 },html: '<tbody>Test email content</tbody>',preheader: 'This is a preview text',})diff --git a/nodejs/src/cdp/services/messaging/email.service.ts b/nodejs/src/cdp/services/messaging/email.service.tsindex bb9a127aeeb2..69757a0efd79 100644--- a/nodejs/src/cdp/services/messaging/email.service.ts+++ b/nodejs/src/cdp/services/messaging/email.service.ts@@ -90,14 +90,14 @@ export class EmailService {throw new Error('Email integration not found')}- this.validateEmailDomain(integration, params)+ const from = this.resolveFromSender(integration)switch (integration.config.provider ?? 'ses') {case 'maildev':- await this.sendEmailWithMaildev(result, params)+ await this.sendEmailWithMaildev(result, params, from)breakcase 'ses':- await this.sendEmailWithSES(result, params)+ await this.sendEmailWithSES(result, params, from)breakcase 'unsupported':@@ -129,12 +129,7 @@ export class EmailService {return result}- private validateEmailDomain(- integration: IntegrationType,- params: CyclotronInvocationQueueParametersEmailType- ): void {- // Currently we enforce using the name and email set on the integration-+ private resolveFromSender(integration: IntegrationType): { email: string; name: string } {if (!integration.config.verified) {throw new Error('The selected email integration domain is not verified')}@@ -143,18 +138,18 @@ export class EmailService {throw new Error('The selected email integration is not configured correctly')}- params.from.email = integration.config.email- params.from.name = integration.config.name+ return { email: integration.config.email, name: integration.config.name }}// Send email to local maildev instance for testing (DEBUG=1 only)private async sendEmailWithMaildev(result: CyclotronJobInvocationResult<CyclotronJobInvocationHogFunction>,- params: CyclotronInvocationQueueParametersEmailType+ params: CyclotronInvocationQueueParametersEmailType,+ from: { email: string; name: string }): Promise<void> {// This can timeout but there is no native timeout so we do our own oneconst mailOptions: SendMailOptions = {- from: params.from.name ? `"${params.from.name}" <${params.from.email}>` : params.from.email,+ from: from.name ? `"${from.name}" <${from.email}>` : from.email,to: params.to.name ? `"${params.to.name}" <${params.to.email}>` : params.to.email,subject: sanitizeEmailSubject(params.subject),text: params.text,@@ -182,7 +177,8 @@ export class EmailService {private async sendEmailWithSES(result: CyclotronJobInvocationResult<CyclotronJobInvocationHogFunction>,- params: CyclotronInvocationQueueParametersEmailType+ params: CyclotronInvocationQueueParametersEmailType,+ from: { email: string; name: string }): Promise<void> {if (!this.sesV2Client) {throw new Error('SES is not configured - set SES_REGION and AWS credentials')@@ -202,7 +198,7 @@ export class EmailService {: {}const sendEmailParams: SendEmailCommandInput = {- FromEmailAddress: params.from.name ? `"${params.from.name}" <${params.from.email}>` : params.from.email,+ FromEmailAddress: from.name ? `"${from.name}" <${from.email}>` : from.email,Destination: {ToAddresses: [params.to.name ? `"${params.to.name}" <${params.to.email}>` : params.to.email],},@@ -223,7 +219,7 @@ export class EmailService {},ConfigurationSetName: 'posthog-messaging',EmailTags: [{ Name: 'ph_id', Value: trackingCode }],- FeedbackForwardingEmailAddress: params.from.email,+ FeedbackForwardingEmailAddress: from.email,}const isTransactionalEmail = result.invocation.hogFunction.metadata?.message_category_type === 'transactional'diff --git a/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.ts b/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.tsindex 7cf55e218fbf..3e3f3a9dd5ed 100644--- a/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.ts+++ b/nodejs/src/cdp/services/messaging/recipient-preferences.service.test.ts@@ -118,7 +118,7 @@ describe('RecipientPreferencesService', () => {email: to,},from: {- email: '[email protected]',+ integrationId: 1,},subject: 'Test Subject',text: 'Test Text',diff --git a/nodejs/src/cdp/templates/_destinations/email/email.template.test.ts b/nodejs/src/cdp/templates/_destinations/email/email.template.test.tsindex a42f7e5d241c..5e673032163f 100644--- a/nodejs/src/cdp/templates/_destinations/email/email.template.test.ts+++ b/nodejs/src/cdp/templates/_destinations/email/email.template.test.ts@@ -22,8 +22,6 @@ describe('email template', () => {},from: {integrationId: 1,- email: '[email protected]',- name: 'Test User',},subject: 'PostHog Notification',text: '',@@ -45,9 +43,7 @@ describe('email template', () => {expect(response.invocation.queueParameters).toMatchInlineSnapshot(`{"from": {- "email": "[email protected]","integrationId": 1,- "name": "Test User",},"html": "","subject": "PostHog Notification",@@ -71,8 +67,6 @@ describe('email template', () => {},from: {integrationId: 1,- email: '[email protected]',- name: 'Test User',},cc: '[email protected], [email protected]',bcc: '[email protected]',diff --git a/nodejs/src/cdp/templates/_destinations/email/email.template.ts b/nodejs/src/cdp/templates/_destinations/email/email.template.tsindex eb685ed43389..45e4d56dc4b8 100644--- a/nodejs/src/cdp/templates/_destinations/email/email.template.ts+++ b/nodejs/src/cdp/templates/_destinations/email/email.template.ts@@ -30,10 +30,7 @@ export const template: HogFunctionTemplate = {email: '{{ person.properties.email }}',name: '',},- from: {- email: '',- name: '',- },+ from: {},replyTo: '',cc: '',bcc: '',diff --git a/nodejs/src/schema/cyclotron.ts b/nodejs/src/schema/cyclotron.tsindex a5b28ebb4161..8343e5128dd2 100644--- a/nodejs/src/schema/cyclotron.ts+++ b/nodejs/src/schema/cyclotron.ts@@ -78,8 +78,6 @@ export const CyclotronInvocationQueueParametersEmailSchema = z.object({}),replyTo: z.string().optional(),from: z.object({- email: z.string(),- name: z.string().optional(),integrationId: z.number(),}),cc: z.string().optional(),diff --git a/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.ts b/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.tsindex 2696f1a4be1c..62809cb41cf9 100644--- a/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.ts+++ b/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.ts@@ -105,10 +105,13 @@ describe('workflowLogic email step "from" validation', () => {logic?.unmount()})- it('flags the step as invalid when "from" has an email but no integrationId (no sender picked)', async () => {+ it.each([+ ['"from" has no integrationId (no sender picked)', {}],+ ['"from" is completely missing', undefined],+ ])('flags the step as invalid when %s', async (_name, fromValue) => {useMocks({get: {- '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({ email: '[email protected]' }),+ '/api/environments/:team_id/hog_flows/:id/': makeWorkflow(fromValue),'/api/projects/:team_id/hog_function_templates/': hangingTemplatesEndpoint,},})@@ -118,52 +121,14 @@ describe('workflowLogic email step "from" validation', () => {await expectLogic(logic).toDispatchActions(['loadWorkflowSuccess'])const result = logic.values.actionValidationErrorsById[EMAIL_NODE_ID]- expect(result).not.toBeNull()expect(result?.valid).toBe(false)expect(result?.errors.email).toBe('Choose who to send this email from')})- it('flags the step as invalid when "from" is completely missing', async () => {- useMocks({- get: {- '/api/environments/:team_id/hog_flows/:id/': makeWorkflow(undefined),- '/api/projects/:team_id/hog_function_templates/': hangingTemplatesEndpoint,- },- })- initKeaTests()- logic = workflowLogic({ id: WORKFLOW_ID, tabId: 'default' })- logic.mount()- await expectLogic(logic).toDispatchActions(['loadWorkflowSuccess'])-- const result = logic.values.actionValidationErrorsById[EMAIL_NODE_ID]- expect(result?.valid).toBe(false)- expect(result?.errors.email).toContain('Choose who to send this email from')- })-- it('flags the step as invalid when integrationId is set but from.email is missing', async () => {- useMocks({- get: {- '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({ integrationId: 42 }),- '/api/projects/:team_id/hog_function_templates/': hangingTemplatesEndpoint,- },- })- initKeaTests()- logic = workflowLogic({ id: WORKFLOW_ID, tabId: 'default' })- logic.mount()- await expectLogic(logic).toDispatchActions(['loadWorkflowSuccess'])-- const result = logic.values.actionValidationErrorsById[EMAIL_NODE_ID]- expect(result?.valid).toBe(false)- expect(result?.errors.email).toContain('Choose who to send this email from')- })-it('does not flag a "from" error when an integration sender has been picked', async () => {useMocks({get: {- '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({- email: '[email protected]',- integrationId: 42,- }),+ '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({ integrationId: 42 }),'/api/projects/:team_id/hog_function_templates/': hangingTemplatesEndpoint,},})@@ -180,7 +145,7 @@ describe('workflowLogic email step "from" validation', () => {it('keeps the email-block error after templates load (function-action branch must not clobber it)', async () => {useMocks({get: {- '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({ email: '[email protected]' }),+ '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({}),'/api/projects/:team_id/hog_function_templates/': loadedTemplatesResponse,},})@@ -197,7 +162,7 @@ describe('workflowLogic email step "from" validation', () => {it('propagates the step error into workflowHasActionErrors', async () => {useMocks({get: {- '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({ email: '[email protected]' }),+ '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({}),'/api/projects/:team_id/hog_function_templates/': hangingTemplatesEndpoint,},})diff --git a/products/workflows/frontend/Workflows/workflowLogic.ts b/products/workflows/frontend/Workflows/workflowLogic.tsindex 1fe338475fb4..b9fae8cb9f01 100644--- a/products/workflows/frontend/Workflows/workflowLogic.ts+++ b/products/workflows/frontend/Workflows/workflowLogic.ts@@ -474,10 +474,9 @@ export const workflowLogic = kea<workflowLogicType>([subject: !emailValue?.subject? 'Subject is required': getTemplatingError(emailValue?.subject, emailTemplating),- from:- !emailValue?.from?.integrationId || !emailValue?.from?.email- ? 'Choose who to send this email from'- : getTemplatingError(emailValue?.from?.email, emailTemplating),+ from: !emailValue?.from?.integrationId+ ? 'Choose who to send this email from'+ : undefined,to: !emailValue?.to?.email? 'To is required': getTemplatingError(emailValue?.to?.email, emailTemplating),