Skip to content

Conversation

@dkoo
Copy link
Contributor

@dkoo dkoo commented Sep 10, 2024

All Submissions:

Changes proposed in this Pull Request:

#3362 removed normalize_contact_data as a filter on the newspack_newsletters_contact_data hook. However, this results in upsert calls that happen outside of this plugin's Sync classes to sync un-normalized metadata.

This PR restores the filter, but this will result in the data from upsert calls from the Sync classes being normalized twice. I'm open to feedback on how this can be improved, but for now this fixes the issue.

How to test the changes in this Pull Request:

  1. On trunk in both this plugin and Newsletters, sign up for newsletter lists as a new reader via the Newsletter Subscription Form block.
  2. Observe in the Logger output and in the connected ESP contact that the metadata synced upon registration contains raw, un-normalized metadata keys (e.g. connected_account instead of NP_Account or current_page_url instead of NP_Registration Page).
  3. Check out this branch, repeat with a different email address and confirm that the synced metadata contains only normalized, prefixed keys.

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?

@dkoo dkoo self-assigned this Sep 10, 2024
@dkoo dkoo requested a review from a team as a code owner September 10, 2024 23:57
Copy link
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

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

Thank you for catching that!

I'll approve because this fixes the regression, but I think we could avoid the double normalization by having a separate filter for the ::subscribe(), which are the instances in which the Newsletters plugin updates a contact with metadata.

All other cases that use ::upsert() are list updates, which do not have metadata.

@github-actions github-actions bot added the [Status] Approved The pull request has been reviewed and is ready to merge label Sep 11, 2024
@leogermani
Copy link
Contributor

Here's an alternative Automattic/newspack-newsletters#1648

@dkoo
Copy link
Contributor Author

dkoo commented Sep 11, 2024

Closing in favor of #1648

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants