Skip to content

Conversation

rmi22186
Copy link
Member

Instructions

  1. PR target branch should be against development
  2. PR title name should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-title-check.yml
  3. PR branch prefix should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-branch-check-name.yml

Summary

In this PR, we make an identify call if emailsha256 passed to selectPlacement differs from the other identity value.

Testing Plan

  • Was this tested locally? If not, explain why.
    Integration tests and tested in an app

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

@rmi22186 rmi22186 changed the title feat: Map emailsha256 to other identity feat: Identify if emailsha256 from selectPlacements differs from 'other' identity Aug 12, 2025
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
64.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

this.identityService.identify({
userIdentities: {
...currentUserIdentities,
other: newEmailSha256 as string
Copy link
Contributor

Choose a reason for hiding this comment

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

With Web you can identify with more than 1 identity at a time right? I just think if you need to identify with either you should just identify with both rather than possibly identifying twice.

@rmi22186 rmi22186 changed the title feat: Identify if emailsha256 from selectPlacements differs from 'other' identity feat: Support hashedEmailUserIdentityType for "other" identity types Sep 18, 2025
@rmi22186 rmi22186 changed the title feat: Support hashedEmailUserIdentityType for "other" identity types feat: Support hashedEmailUserIdentityType for "other" identity type Sep 18, 2025
@rmi22186 rmi22186 changed the title feat: Support hashedEmailUserIdentityType for "other" identity type feat: SDKE-221 Support hashedEmailUserIdentityType for "other" identity type Sep 18, 2025
newHashedEmail = mappedAttributes['emailsha256'] as string || undefined;
}

const emailChanged = !!(newEmail && (!currentEmail || currentEmail !== newEmail));
Copy link
Contributor

Choose a reason for hiding this comment

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

So !! is a double not right so it doesn't invert like not(!), it just converts to a boolean?

So this would be = ((newEmail != nil && currentEmail == nil) || (newEmail != nil && currentEmail !== newEmail))

Copy link
Contributor

@BrandonStalnaker BrandonStalnaker left a comment

Choose a reason for hiding this comment

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

Looks good as long as my understanding of the logic is right

Copy link

@Mansi-mParticle Mansi-mParticle left a comment

Choose a reason for hiding this comment

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

Logic looks good to me

): void {
const { userAttributeFilters, settings } = roktConfig || {};
const { placementAttributesMapping } = settings || {};
this.configSettings = settings;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If configSettings is just a copy of settings, we should move it above the extraction of placementAttributesMapping, and combine the destructuring of placementAttributesMapping and hashedEmailUserIdentityType.

Copy link
Member Author

@rmi22186 rmi22186 Sep 23, 2025

Choose a reason for hiding this comment

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

@alexs-mparticle not sure I follow. Destructuring hashedEmaiLuserIdenittyType from settings so that I can use it in selectPlacements would require me to place a new setting on the Rokt class. Is that what you are suggesting? It's not used in the current init function

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you do this here:

        const { userAttributeFilters, settings } = roktConfig || {};
        const { placementAttributesMapping, hashedEmailUserIdentityType } = settings || {}; 

Then you can avoid doing this later in the file:

     const { hashedEmailUserIdentityType = null } = this.configSettings || {};

And then we don't need to store configSettings on this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Closing the loop here - confirmed with Alex that we shodl set it on the Rokt Class and not just destructure it so it can be used later.

newHashedEmail = mappedAttributes['emailsha256'] as string || undefined;
}

const emailChanged = !!(newEmail && (!currentEmail || currentEmail !== newEmail));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would avoid using double bang (!!) in these checks because it makes it hard to read what's going on here. I think we created https://go.mparticle.com/work/SQDSDKS-7338 to refactor this into something readable, so now would be a great time to clean this up.

@rmi22186 rmi22186 force-pushed the fix/SQDSDKS-7619-compare-emailsha256-with-other branch from a729496 to bd7785f Compare September 23, 2025 01:39
@rmi22186
Copy link
Member Author

@alexs-mparticle please take another look

Comment on lines 1096 to 1097
// Reset mocks
jest.clearAllMocks();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you still need to do this since it's in the beforeEach?

Suggested change
// Reset mocks
jest.clearAllMocks();

Copy link

sonarqubecloud bot commented Oct 6, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
26.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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.

4 participants