Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(esp-sync): queue data events sync to run once #3661

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

miguelpeixe
Copy link
Member

@miguelpeixe miguelpeixe commented Jan 9, 2025

All Submissions:

Changes proposed in this Pull Request:

Since #3616, data events are grouped and handled in the same execution. This PR leverages that change to also optimize multiple syncs that different data events may trigger.

To restrict that behavior to data events only, this PR implements the feature from #3383 so we can be aware of whether we're running under a data event or not.

Syncs performed under data events should now only run once per email, containing the latest payload.

For debugging, the sync contexts are grouped to be logged, which can look like this:

image

To ensure we always have the most recent data, when running on shutdown the most recent contact data is fetched using a new get_contact_data() method, which was decoupled from the sync_contact() method.

How to test the changes in this Pull Request:

  1. Make sure you have a RAS setup with a membership plan and a subscription product activating it
  2. In a fresh session, go through the Checkout Button flow and complete the subscription purchase
  3. Confirm via logs that a bunch of data events gets dispatched (membership_status_active, membership_saved, reader_registered)
  4. Confirm that only one Newspack_Newsletters_Contacts::upsert is logged
  5. Confirm the contact is added to your ESP

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@miguelpeixe miguelpeixe marked this pull request as ready for review January 10, 2025 19:11
@miguelpeixe miguelpeixe requested a review from a team as a code owner January 10, 2025 19:11
@miguelpeixe miguelpeixe self-assigned this Jan 10, 2025
@miguelpeixe miguelpeixe marked this pull request as draft January 10, 2025 19:24
@miguelpeixe miguelpeixe marked this pull request as ready for review January 10, 2025 19:38
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.

1 participant