Skip to content

feat: Identify if Provided Email in Rokt SelectPlacements#351

Merged
BrandonStalnaker merged 4 commits intodevelopmentfrom
feat/SQDSDKS-7247-Identify-If-Provided-Email-In-Rokt
May 14, 2025
Merged

feat: Identify if Provided Email in Rokt SelectPlacements#351
BrandonStalnaker merged 4 commits intodevelopmentfrom
feat/SQDSDKS-7247-Identify-If-Provided-Email-In-Rokt

Conversation

@BrandonStalnaker
Copy link
Copy Markdown
Collaborator

Summary

  • After a developer calls selectPlacements with email, we should check to see if email is on the user yet. If it isn’t, we should call identify with email (along with all other current user identities)

Testing Plan

  • Was this tested locally? If not, explain why.
  • Tested live and with unit tests

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

@BrandonStalnaker BrandonStalnaker self-assigned this May 12, 2025
@BrandonStalnaker BrandonStalnaker changed the title feat: Identfiy if Provide Email in Rokt SelectPlacements feat: Identify if Provided Email in Rokt SelectPlacements May 13, 2025

- (void)confirmEmail:(NSString * _Nullable)email user:(MParticleUser * _Nullable)user completion:(void (^)(MParticleUser *_Nullable))completion {
if (email && email != user.identities[@(MPIdentityEmail)]) {
MPIdentityApiRequest *identityRequest = [MPIdentityApiRequest requestWithUser:user];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should log here a log that says something more explicit about the current email vs the passed in email. Something like:
The email sent to selectPlacements (foo@gmail.com) is different from what is on the current user (bar@gmail.com). Double check your implementation to confirm this is your intended behavior

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That kinda reads like an error message to me and might lead customers to think they are doing something wrong. Is that your intent? Maybe the second sentence could be more like. We will attempt to update the current user with this email but to receive a Rokt Layout as quickly as possible, sync the email identity to mParticle as soon as you receive it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think actually there are 2 scenarios here that should be considered for messaging purposes. both would result in calling identify, but one i think is a bug

  1. if (selectPlacements email && !currentUser.email) // this is not a bug, as there's a chance that someone is checking out as guest, and so they'd only get the email once
  2. if (selectPlacements email && currentUser.email && selectPlacements email !== currentUser.email) --> this i think is a bug. if the user has an email, then the selectPlacements email should match it. we should log that as a warning at a minimum to the user to let them know
    the first scenario doesn't need any logging since it's a valid case, the 2nd one does need a log

NSLog(@"Failed to automatically update email from selectPlacement: %@", error);
completion(user);
} else {
NSLog(@"Updated email identity based off selectPlacement's attributes: %@", apiResult.user.identities.description);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this provide a description of all the identities that are on the user? Cursor is telling me something like the following would come back:
{
7 = "user@example.com"; // MPIdentityEmail
1 = "customer123"; // MPIdentityCustomerId
2 = "fb123456"; // MPIdentityFacebook
4 = "google123"; // MPIdentityGoogle
3 = "twitter123"; // MPIdentityTwitter
5 = "ms123456"; // MPIdentityMicrosoft
6 = "yahoo123"; // MPIdentityYahoo
19 = "+1234567890"; // MPIdentityMobileNumber
}


Is that accurate? If so, i think having it be by number is confusing.

I think just confirming which email was used is fine here also.  **_Or_** if you add the above suggestion to give more detailed emails in the above log I recommended, then it would be redundant here and could be removed.  

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah unfortunately identities are stored with the key being an integer. I could change it to just be the email.

XCTAssertEqualObjects(testResult, expectedResult, @"Mapping does not match .");
}

- (void)testSelectPlacementsIdentifyUser {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a test where there is an email (foo@gmail.com) and (bar@gmail.com) is set on selectPlacements - then assert that identify was called with bar@gmail.com?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll try. Identity is really tricky to mock well but it should be doable

@BrandonStalnaker BrandonStalnaker requested a review from rmi22186 May 14, 2025 15:49
Copy link
Copy Markdown
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

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

lgtm!

@BrandonStalnaker BrandonStalnaker changed the base branch from main to development May 14, 2025 20:35
@BrandonStalnaker BrandonStalnaker merged commit a0422bc into development May 14, 2025
11 of 12 checks passed
@BrandonStalnaker BrandonStalnaker deleted the feat/SQDSDKS-7247-Identify-If-Provided-Email-In-Rokt branch May 14, 2025 20:40
mparticle-automation added a commit that referenced this pull request May 21, 2025
# [8.31.0](v8.30.3...v8.31.0) (2025-05-21)

### Bug Fixes

* MPAppNotificationHandler webpageURL issue ([#353](#353)) ([bebb504](bebb504))

### Features

* Identify if Provided Email in Rokt SelectPlacements ([#351](#351)) ([a0422bc](a0422bc))
@mparticle-automation
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 8.31.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants