Repository navigation
PM-6720 - store the sendgrid message id - #24
Conversation
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
The change still has a moderate unresolved issue in src/forms/forms.service.ts where sendgridMessageIds() can misorder results due to nullable emailSentAt sorting (NULLs first) and uses an inefficient Map-to-array append pattern that allocates on each addition.
1 open issue
What changed in this PR
This pull request adds end-to-end support for persisting SendGrid message IDs for email deliveries and surfacing them in submission reports (JSON + CSV) for forms that use the sendgrid-email processor flow, enabling traceability into SendGrid email logs.
Changes:
- Adds
sendgridMessageIdandemailSentAttoProcessorDelivery(Prisma schema + DB migration). - Extends submissions reporting to conditionally include
sendgrid_message_ids(label: “SendGrid logs”) and populate it per submission. - Updates documentation and adds integration coverage for conditional inclusion and CSV formatting.
Review notes (requires updates):
- Filter the query by
flow.actionto ensure onlysendgrid-emaildeliveries are included (avoid future cross-flow leakage if the column is populated elsewhere). (moderate) - Ensure ordering matches documented “oldest send first” even when
emailSentAtis NULL (Postgres NULL sort behavior can violate expected ordering). (moderate) - Avoid repeated array spreading when building per-submission ID arrays; mutate/push into the existing array to prevent unnecessary allocations. (nit)
Approval Readiness
This pull request requires changes.
| File | Reviewed change summary |
|---|---|
test/forms.integration.spec.ts |
Adds integration coverage for conditional sendgrid_message_ids inclusion and CSV JSON-array formatting. |
src/forms/forms.service.ts |
Implements conditional report column inclusion and DB fetch/grouping logic for SendGrid message IDs per submission. |
prisma/schema.prisma |
Extends ProcessorDelivery with sendgridMessageId and emailSentAt. |
prisma/migrations/20261104010000_processor_delivery_sendgrid_message/migration.sql |
Adds the new columns at the database level. |
docs/data-model.md |
Documents the new ProcessorDelivery fields and lifecycle. |
docs/api.md |
Documents the new sendgrid_message_ids report column semantics and CSV representation. |
Review effort: Balanced
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟢 Approval recommended
The review evidence shows the feature implemented end-to-end (schema/migration, service logic, reporting outputs) with corresponding documentation and integration test coverage, and it notes no remaining open concerns.
No open issues 🎉
1 resolved since last review
Review effort: Balanced

This pull request adds support for reporting SendGrid message IDs in submission reports for forms that use the
sendgrid-emailprocessor flow. This allows users to trace each email sent for a submission, with IDs linked to SendGrid’s email logs. The change includes a schema migration, backend logic to collect and display these IDs, and documentation and test updates.Database and Data Model Updates:
sendgridMessageIdandemailSentAtcolumns to theProcessorDeliverytable to store SendGrid message IDs and their sent timestamps, populated from email-service-v6 reports. [1] [2]Backend Logic and API Enhancements:
sendgrid_message_idscolumn (labeled "SendGrid logs") for forms with an email processor flow, listing all SendGrid message IDs for each submission in send order. [1] [2] [3] [4] [5]sendgridMessageIdsmethod to efficiently fetch and group message IDs per submission.Documentation and Tests:
sendgrid_message_idsreport column, its format, and how IDs are linked to SendGrid logs.