feat(integrations): implement profile metadata (identity, registration, engagement)#4624
feat(integrations): implement profile metadata (identity, registration, engagement)#4624chickenn00dle wants to merge 4 commits intotrunkfrom
Conversation
2e3b777 to
c11dc18
Compare
973af86 to
c2dab85
Compare
There was a problem hiding this comment.
Pull request overview
Implements real metadata export for Reader Activation “profile” contact metadata by populating Identity, Registration, and Engagement metadata classes, and adds unit tests to validate the new behaviors.
Changes:
- Implemented
get_metadata()for Identity, Registration, and Engagement contact metadata classes (including new registration UTM persistence). - Updated sync metadata class list to use the new metadata sections and improved integration-specific sync logging.
- Added unit tests covering Identity/Registration/Engagement metadata output.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit-tests/class-test-registration-metadata.php | Adds unit coverage for Registration metadata fields (date, page, strategy, UTM). |
| tests/unit-tests/class-test-identity-metadata.php | Adds unit coverage for Identity fields (name/email/account/role/verified/connected account). |
| tests/unit-tests/class-test-engagement-metadata.php | Adds unit coverage for Engagement fields (timestamps, paywall hits, favorite categories, payment fields, total paid). |
| src/blocks/reader-registration/index.php | Adjusts referer URL handling for reCAPTCHA and stored registration metadata. |
| includes/reader-activation/sync/contact-metadata/class-registration.php | Implements Registration metadata (including UTM meta lookup). |
| includes/reader-activation/sync/contact-metadata/class-identity.php | Implements Identity metadata from WP user fields and user meta. |
| includes/reader-activation/sync/contact-metadata/class-engagement.php | Implements Engagement metadata from Reader Data and WooCommerce order/customer data. |
| includes/reader-activation/sync/class-metadata.php | Switches non-legacy metadata class list to Identity/Registration/Engagement + others. |
| includes/reader-activation/sync/class-contact-sync.php | Moves debug logging into integration loop and logs integration-prepared payloads. |
| includes/reader-activation/sync/class-contact-metadata.php | Updates date formatting docblock to match current formatter behavior. |
| includes/reader-activation/class-reader-activation.php | Captures/saves registration UTM params; minor formatting change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
leogermani
left a comment
There was a problem hiding this comment.
Looks great. I left one minor comment/request and have one question.
I see that you are now storing the registration UTMs as user meta. This is nice, but should we add a fallback and look for utms in the URL if the meta is not there? I'm thinking on the situation of syncing users that registered before this change. Not sure if we need something similar for payment_page utm...
| 'email' => $this->user->user_email, | ||
| 'Account' => (string) $this->user->ID, | ||
| 'User_Role' => ! empty( $roles ) ? reset( $roles ) : '', | ||
| 'verified' => (bool) \get_user_meta( $this->user->ID, Reader_Activation::EMAIL_VERIFIED, true ), |
There was a problem hiding this comment.
Let's use Reader_Activation::is_reader_verified instead?
All Submissions:
Changes proposed in this Pull Request:
Implements
get_metadata()for the three profile contact metadata classes that were previously returning empty arrays: Identity, Registration, and Engagement.Identity (7 fields):
first_name,last_name,email— from WordPress user dataAccount— WordPress user IDUser_Role— first WordPress role assigned to the userverified— whether the reader has verified their email (fromnp_reader_email_verifieduser meta)Connected_Account— SSO provider used to register, if any (fromnp_reader_connected_accountuser meta)Registration (6 fields):
Registration_Date— account creation date, formatted asY-m-d H:i:sRegistration_Page— URL where the reader registered (from user meta)Registration_Strategy— how the reader registered: newsletter, checkout, registration-wall, etc. (from user meta)Registration_UTM_Source,Registration_UTM_Medium,Registration_UTM_Campaign— parsed from the registration page URL query parametersEngagement (10 fields):
First_Visit_Date,Last_Active— from the Reader Data store (JS millisecond timestamps converted toY-m-d H:i:s)Paywall_Hits— integer count from the Reader Data storeFavorite_Categories— category IDs from the Reader Data store, converted to a comma-separated string of category namesPayment_Page— URL of the most recent checkout page (from the latest completed WC order's_newspack_referermeta)Payment_UTM_Source,Payment_UTM_Medium,Payment_UTM_Campaign— UTM data from the latest completed WC orderTotal_Paid— lifetime total spent viaWC_Customer::get_total_spent()Closes https://linear.app/a8c/issue/NPPD-1389/implement-profile-fields-identity-engagement-registration
How to test the changes in this Pull Request:
wp-config.php:?utm_source=test&utm_medium=email&utm_campaign=spring)First_Visit_Date,Last_Active,Paywall_Hits,Favorite_Categories,Payment_Page,Payment_UTM_*, andTotal_Paid) are syncedOther information: