Skip to content

Conversation

@jacobpenny
Copy link

@jacobpenny jacobpenny commented Oct 24, 2025

Changes

New environment variables

This PR adds five settings/environment variables which allow switching Basket's backend from cTms to Braze in a gradual way. They are:

BRAZE_PARALLEL_WRITE_ENABLE

When True Basket will send write operations (newsletter subscriptions, etc.) to both cTms and Braze. Side-effects such as sending confirmation emails will only occur once.

BRAZE_READ_WITH_FALLBACK_ENABLE

When True Basket will first send read operations (get user info, etc.) to Braze and will fall back to cTms if an error occured.

BRAZE_ONLY_WRITE_ENABLE

When True Basket will only send write operations to Braze (and not to cTms at all).

BRAZE_ONLY_READ_ENABLE

When True Basket will only read from Braze (and not from cTms at all).

BRAZE_CTMS_SHIM_ENABLE

If a request only provides a token or fxa_id we are unable to look up a user in Braze until the token/fxa_id migration is complete. When True Basket will use a shim to fetch a user's email from cTms when in this situation. This email is then used to look up and/or update the user in Braze.

Implementation Details

Care was taken to modify the existing Basket logic as little as possible. In order to accomplish this a Braze class with the same interface as the CTMS class was created to be used as a near drop-in replacement.

In order to facilitate the gradual switch to Braze (which calls for an initial phase where we write to both backends), the above settings were introduced and endpoint logic was parametized to allow us to choose which backend to use (via a use_braze_backend option). Although this PR's diff is large most endpoint changes were fairly systematic.

@jacobpenny jacobpenny changed the title Development Switch backend from cTms to Braze Nov 14, 2025
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.

5 participants