-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(emails): pivot to a simpler version of email sending functionality #967
Draft
benjaminpaige
wants to merge
82
commits into
main
Choose a base branch
from
eco
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
benjaminpaige
temporarily deployed
to
eco-kibana
January 4, 2025 07:56 — with
GitHub Actions
Inactive
benjaminpaige
temporarily deployed
to
eco-kibana
January 4, 2025 15:45 — with
GitHub Actions
Inactive
benjaminpaige
temporarily deployed
to
eco-kibana
January 4, 2025 21:13 — with
GitHub Actions
Inactive
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎫 Linked Ticket
Ticket to close
💬 Description / Notes
This change adds additional functionality to the email sending process for initial and subsequent submissions.
I think RespondToRAIWithdrawal is still missing, but it can be a follow-up. The code in this section is changing quickly, so I'd like to get this code in and tested so it doesn't have to keep being updated from changes that are made to the transform and sync functionality.
Overview
This changeset introduces functionality that sends email notifications to both state and CMS users when specific initial workflow events occur during the management of state plans. By integrating with AWS SES for email delivery and Kafka for event-driven triggers, the application now automatically notifies relevant stakeholders (e.g., state plan submitters, CMS review teams) at key moments such as new Medicaid or CHIP submissions, temporary extensions, and package withdrawals.
Email Sending Functionality and Trigger Events
New code monitors Kafka-based events that correspond to particular actions in the state plan workflow. When an event such as "new-medicaid-submission", "new-chip-submission", "temp-extension", or "withdraw-package" occurs, the system retrieves the necessary email templates and recipient addresses. It then sends a properly formatted HTML (and text) email via AWS SES.
These notifications target both state-level users (e.g., plan submitters and other state staff) and CMS teams (e.g., State Review Teams, CPOC users). For certain events, both groups receive relevant, custom-tailored messages to ensure all stakeholders remain informed.
Integration with Existing Codebase
New and Modified Files and Modules
lib/lambda/processEmails.ts
: Core lambda function that processes Kafka records and sends emails based on event type and authority.lib/lambda/processEmails.test.ts
: Introduces unit tests ensuring reliability of email processing functionality.lib/lambda/sinkMain.ts
andlib/lambda/sinkMainProcessors.ts
: Adjusted to handle new event topics and integrate with the email sending pipeline.lib/libs/email/
directory: Contains email templates, content components, and helper functions. Newly added files and refactored functions for retrieving and formatting recipient lists, and obtaining email templates depending on the event and authority.lib/libs/email/getAllStateUsers.ts
: Retrieves state user email addresses from Cognito, now returning a formatted address list for direct email sending.lib/libs/email/content/
directories, each designed to handle a specific event and audience (CMS or state).Configuration and Environment Variables
Several new environment variables are introduced to support email functionality:
emailAddressLookupSecretName
: Identifies the AWS Secrets Manager secret containing email-related configuration.applicationEndpointUrl
: URL to the application’s frontend, included in the emails as a link.osDomain
,indexNamespace
,region
: Support OpenSearch lookups and AWS region configuration.DLQ_URL
: Dead-letter queue for failed message processing.userPoolId
: The Cognito User Pool ID used to fetch state users’ email addresses.configurationSetName
: SES configuration set for tracking email sending metrics.isDev
: Flags whether the environment is development, enabling test mode (e.g., routing all emails to a dev mailbox).Third-Party Libraries and Dependencies
@aws-sdk/client-ses
: Used to send emails through AWS SES.p-limit
: Limits concurrency when sending multiple emails simultaneously.Business Logic, Data Models, and Workflow Adjustments
Prior to these changes, the application processed workflow events without sending automatic notifications. Now, when records are processed from Kafka topics (e.g., events representing new package submissions or withdrawals), the system:
These logic additions ensure that each significant workflow milestone triggers timely notifications, reducing manual follow-up and improving communication among stakeholders.
Test Coverage and Reliability
Newly added and updated tests ensure robust validation of the email sending feature:
lib/lambda/processEmails.test.ts
: Verifies that theprocessEmails
handler correctly processes both empty and valid records without errors.lib/libs/email/__tests__/getAllStateUsers.test.ts
: Confirms correct retrieval and formatting of state user email addresses.lib/libs/email/content/email-components.test.tsx
: Ensures email component functions correctly identify and format recipient lists.These tests improve maintainability and reliability, ensuring future changes don’t break the new notification functionality.
Documentation Updates
While no explicit documentation files are included, the changes are structured in a manner that is largely self-documenting. Future maintainers should reference:
Impact and Forward-Looking Summary
The introduction of automated email notifications represents a significant step forward in the application's communication capabilities. By integrating email sending into the event-driven architecture, stakeholders will receive timely notifications for important submission and workflow changes. As the system evolves, new events and user categories can be easily integrated, ensuring consistent and reliable communication that scales with the project’s growth.