Skip to content

PM-6720 - store the sendgrid message id - #24

Merged
vas3a merged 2 commits into
developfrom
PM-6720_sendgrid-messageid
Nov 6, 2026
Merged

vas3a merged 2 commits into
developfrom
PM-6720_sendgrid-messageid

Conversation

@vas3a

@vas3a vas3a commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

This pull request adds support for reporting SendGrid message IDs in submission reports for forms that use the sendgrid-email processor 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:

  • Added sendgridMessageId and emailSentAt columns to the ProcessorDelivery table to store SendGrid message IDs and their sent timestamps, populated from email-service-v6 reports. [1] [2]
  • Updated the data model documentation to describe these new fields and their lifecycle.

Backend Logic and API Enhancements:

  • The submissions report now includes a sendgrid_message_ids column (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]
  • Implemented the sendgridMessageIds method to efficiently fetch and group message IDs per submission.

Documentation and Tests:

  • Updated API documentation to explain the new sendgrid_message_ids report column, its format, and how IDs are linked to SendGrid logs.
  • Added integration tests to verify that the report includes the SendGrid message IDs only for forms with an email flow, and that the CSV export contains these IDs as a JSON array.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 sendgridMessageId and emailSentAt to ProcessorDelivery (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.action to ensure only sendgrid-email deliveries are included (avoid future cross-flow leakage if the column is populated elsewhere). (moderate)
  • Ensure ordering matches documented “oldest send first” even when emailSentAt is 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

Comment thread src/forms/forms.service.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

@vas3a
vas3a merged commit 15b854e into develop Nov 6, 2026
5 checks passed
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