Skip to content

PIR: Add handling of GenerateEmail action#8294

Open
landomen wants to merge 2 commits into
feature/domen/pir-email-flexibility-step-actionfrom
feature/domen/pir-email-flexibility-generate-email
Open

PIR: Add handling of GenerateEmail action#8294
landomen wants to merge 2 commits into
feature/domen/pir-email-flexibility-step-actionfrom
feature/domen/pir-email-flexibility-generate-email

Conversation

@landomen
Copy link
Copy Markdown
Contributor

@landomen landomen commented Apr 15, 2026

Task/Issue URL: https://app.asana.com/1/137249556945/project/481882893211075/task/1213993026941869?focus=true

Description

Adds logic for GenerateEmail action and refactors the implicit email handling to use same approach as the new explicit one.

Steps to test this PR

Will be testable later when feature is complete.

UI changes

No UI changes


Note

Medium Risk
Moderate risk because it changes PIR action sequencing and how generated emails are propagated into script request data, which can affect opt-out/email-confirmation flows and retries across multiple broker step types.

Overview
Adds first-class handling for BrokerAction.GenerateEmail: ExecuteBrokerStepActionEventHandler now requests email generation when encountering this action, and EmailReceivedEventHandler advances to the next action when the current action was GenerateEmail.

Refactors the legacy implicit needsEmail path to stop mutating profileToOptOut.email; instead it stores the email in State.generatedEmailData and injects the email into UserProfile.extractedProfile only when building script request params (including retry cases), and fails fast if the implicit path is hit for ScanStep.

Updates and expands unit tests to cover explicit vs implicit flows, scan-step behavior, pixel emission, and ensuring existing generatedEmailData prevents re-requesting email generation.

Reviewed by Cursor Bugbot for commit 9ef29ae. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Contributor Author

landomen commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6eac148. Configure here.

val updatedProfileWithEmail = currentBrokerStep.profileToOptOut.copy(
email = (event as EmailReceived).generatedEmailData.emailAddress,
)
attemptFireOptOutStagePixel(currentBrokerStep, state)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should revisit if we want to fire pixels for scan and optout/email confirmation?

actionToExecute,
pushDelay,
completeRequestData(currentBrokerStep, actionToExecute, state.profileQuery, requestData),
completeRequestData(currentBrokerStep, actionToExecute, state.profileQuery, requestData, state.generatedEmailData),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this will still change once we introduce the GetEmailData right?

@landomen landomen force-pushed the feature/domen/pir-email-flexibility-step-action branch from 57b9781 to feb3698 Compare April 29, 2026 05:11
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-generate-email branch from f2f0cf0 to 9fde6a4 Compare April 29, 2026 05:13
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-step-action branch from feb3698 to b9ac7be Compare April 29, 2026 05:13
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-generate-email branch from 9fde6a4 to ec6dfe0 Compare May 15, 2026 15:49
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-step-action branch from b9ac7be to 2b18366 Compare May 15, 2026 15:49
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-step-action branch from 2b18366 to e974a7d Compare May 15, 2026 16:19
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-generate-email branch from ec6dfe0 to a5d392a Compare May 15, 2026 16:19
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-generate-email branch from a5d392a to f9b69ff Compare May 19, 2026 11:00
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-step-action branch from e974a7d to 9cb269d Compare May 19, 2026 11:00
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-step-action branch from 9cb269d to 81eaf81 Compare May 21, 2026 17:48
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-generate-email branch from f9b69ff to 8197210 Compare May 21, 2026 17:48
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-step-action branch from 81eaf81 to aa8e6f8 Compare May 22, 2026 06:46
@landomen landomen force-pushed the feature/domen/pir-email-flexibility-generate-email branch from 8197210 to 9ef29ae Compare May 22, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants