refactor: do batched requests for braze tracking in lic assignment #569
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.
Description
Currently, each call to track license lifecycle state (e.g. during license assignment) seems to make 2 calls to braze per license:
create_braze_alias
.track_user
.This is an attempt to utilize the braze API more efficiently. If we don’t, we’re going to end up making around 1 million calls to braze during the execution of a script that assigns 400,000 emails. The risk here is that we get rate-limited, or just see "normal" failed requests to braze, and many users/licenses end up in a partially tracked state that leads to difficulties/support-overhead during license activation.
Another subtle change here: as part of assignment, we conditionally want to send assignment notification emails. These require that we have braze aliases setup. I've re-ordered the chain of tasks we kick off to only explicitly create braze aliases in a task IF we're going to send those notifications.
Note that the task to track license changes also creates braze aliases during assignment (so we can track users who don't have an lms_user_id yet). It's fine to do the alias tracking call multiple times (its idempotent on the Braze side), especially now that we're doing all alias creation as batched work. But with this second change, we now will only create aliases at one point (during lifecycle tracking) when assignment notification is disabled.
Link to the associated ticket: https://openedx.atlassian.net/browse/ENT-8304
Testing considerations
Post-review
Squash commits into discrete sets of changes