Skip to content

feat: [AB#16890] real-time GovDelivery Communications Cloud subscribe/unsubscribe#12627

Draft
hinzed1127 wants to merge 1 commit intomainfrom
dh-govdelivery-integration
Draft

feat: [AB#16890] real-time GovDelivery Communications Cloud subscribe/unsubscribe#12627
hinzed1127 wants to merge 1 commit intomainfrom
dh-govdelivery-integration

Conversation

@hinzed1127
Copy link
Copy Markdown
Contributor

@hinzed1127 hinzed1127 commented Mar 10, 2026

Description

This integrates with the GovDelivery Communications Cloud API. When users make updates to their Contact & Notifications settings (via /profile?tab=contact-notifications), changes to a user's email or newsletter preferences are now propagated to and persisted with GovDelivery.

The info organization and UX of the GovDelivery documentation is pretty rough and I leaned heavily on Claude to get things initially going, but everything has been updated, reviewed, and validated by me.

Ticket

This pull request resolves #16890 and #16365.

Approach

  • A new client has added specifically for the Communications Cloud API. While there is an existing GovDeliveryNewsletterClient, that uses the Script Service API and an API key for auth, whereas the Communications Cloud API requires basic auth tied to a specific account. Given that difference, I opted to just create a new client. We should also be able to use this new client exclusively if we choose to deprecate GovDeliveryNewsletterClient in the future
  • Backend: syncNewsletterSubscription is the core business logic. On failure, userRouter returns a HTTP 502 response and skips the database save that updates user data values for email and/or receiveNewsletter
  • Frontend: Any errors propagate through post()useUserDataprofile.tsxContactTabPanel, which renders specific error alerts. User edits to email/newsletter fields clear the error.

Steps to Test

When .env values that hit GovDelivery's staging environment are omitted, Wiremock values default to mocking successful calls.

Testing mocked failure modes

Testing subscribe failure:

  1. Start WireMock and set subscribe to failure mode:
    curl -X PUT http://localhost:9000/__admin/scenarios/GovDeliverySubscribe/state -d '{"state": "Failure"}'
  2. In profile, check "Receive newsletter" and click the "Save" button.
  3. Verify this error alert appears: We were unable to subscribe you to the newsletter. Your changes were not saved. Please try again.
  4. Verify changes are NOT saved (uncheck the box and refresh - it should still be unchecked).
  5. Edit the email field - the error alert should disappear.
  6. Reset WireMock to success:
    curl -X PUT http://localhost:9000/__admin/scenarios/GovDeliverySubscribe/state -d '{"state": "Started"}'
  7. Try subscribing again - it should now succeed.

Testing unsubscribe failure:

  1. Subscribe successfully first (with WireMock in Started state).
  2. Set unsubscribe to failure mode:
    curl -X PUT http://localhost:9000/__admin/scenarios/GovDeliveryUnsubscribe/state -d '{"state": "Failure"}'
  3. Uncheck "Receive newsletter" and click Save.
  4. Verify error alert: We were unable to unsubscribe you from the newsletter...
  5. Verify newsletter checkbox is still checked after refresh.

Testing email update failure:

  1. Subscribe to newsletter first.
  2. Set updateEmail to failure mode:
    curl -X PUT http://localhost:9000/__admin/scenarios/GovDeliveryUpdateEmail/state -d '{"state": "Failure"}'
  3. Change email address and click Save.
  4. Verify error alert: We were unable to update your newsletter subscription with your new email....
  5. Verify the email change is NOT saved.

Testing updates to GovDelivery's staging environment

See me for a walkthrough of the staging environment and validating that changes propagate through when the correct .env values are set

Notes

  • WireMock testing documentation is available in the new api/wiremock/mappings/README.md
  • Right now we have a dedicated account to integrate with GovDelivery's staging environment. We'll need to have a account with similar permissions/access created for their prod environment before this can go live

Code author checklist

  • I have rebased this branch from the latest main branch
  • I have performed a self-review of my code
  • My code follows the style guide
  • I have created and/or updated relevant documentation on the engineering documentation website
  • I have not used any relative imports
  • I have pruned any instances of unused code
  • I have not added any markdown to labels, titles and button text in config
  • If I added/updated any values in userData (including profileData, formationData etc), then I added a new migration file
  • I have checked for and removed instances of unused config from CMS
  • If I added any new collections to the CMS config, then I updated the search tool and cmsCollections.ts (see CMS Additions in Engineering Reference/FAQ on the engineering documentation site)
  • I have updated relevant .env values in .env-template, in Bitwarden, and in our workspaces
    • TODO: update this for deployed sites via GitHub secrets
  • I have added the request-reviewer tag on github to request reviews

@hinzed1127 hinzed1127 marked this pull request as draft March 10, 2026 23:07
@hinzed1127 hinzed1127 force-pushed the dh-govdelivery-integration branch from 6ee36b2 to e91a970 Compare March 10, 2026 23:53
@hinzed1127 hinzed1127 marked this pull request as ready for review March 11, 2026 00:11
@hinzed1127 hinzed1127 force-pushed the dh-govdelivery-integration branch from e91a970 to 1a1d0b4 Compare March 11, 2026 14:48
@hinzed1127
Copy link
Copy Markdown
Contributor Author

Adding a blocked label here while account permissions troubleshooting continues with the GovDelivery support team

@hinzed1127 hinzed1127 force-pushed the dh-govdelivery-integration branch from 1a1d0b4 to ecf67e9 Compare March 31, 2026 16:18
@hinzed1127 hinzed1127 marked this pull request as draft April 6, 2026 17:14
@hinzed1127 hinzed1127 force-pushed the dh-govdelivery-integration branch from ecf67e9 to 438b06f Compare April 6, 2026 22:53
Wires up the GovDelivery Communications Cloud API v1 to handle
newsletter subscribe, unsubscribe, and email-change when users update
their profile in the Contact & Notifications tab.
@hinzed1127 hinzed1127 force-pushed the dh-govdelivery-integration branch from 438b06f to a917230 Compare April 7, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant