feat: Support adding identities to select placement attributes#35
Conversation
| filteredAttributes = addIdentityAttributes( | ||
| filteredAttributes, | ||
| filteredUser | ||
| ); |
There was a problem hiding this comment.
We're merging all the different user attributes below, so I think instead of mutating the existing filtered attributes, we should create a new object that will be merged below. I think this would make logging and debugging easier in the future.
Also, it looks like you're just adding the user identities into the select placement attributes so you really don't need to modify the filtered attributes (i think).
You can just pull the identities out the of the user and just add them into the select placements attributes.
var filteredUserIdentities = filteredUser.getUserIdentities().userIdentities;
// Then below:
var selectPlacementsAttributes = mergeObjects(
filteredAttributes,
filteredUserIdentities,
optimizelyAttributes,
{
mpid: mpid,
}
);
| * @param {Object} filteredUser - The filtered user object containing identities | ||
| * @returns {Object} The attributes object with added identities | ||
| */ | ||
| function addIdentityAttributes(attributes, filteredUser) { |
There was a problem hiding this comment.
If the purpose of this code change is to extract the user identities into the selectPlacement attributes, this function should a wrapper around filteredUser.getUserIdentities().userIdentities that simply returns the identities to be merged later.
It shouldn't be mutating the attributes at all, which can lead to side effects.
| .getMPID() | ||
| .should.equal('123'); | ||
| window.mParticle.forwarder.filters.filteredUser | ||
| .getMPID().should.equal('123'); |
There was a problem hiding this comment.
Please fix this linting error.
| }; | ||
| }); | ||
|
|
||
| it('should handle case when userIdentities is null but userAttributes exist', async () => { |
There was a problem hiding this comment.
| it('should handle case when userIdentities is null but userAttributes exist', async () => { | |
| it('should send userAttributes if userIdentities is null but userAttributes exists', async () => { |
Co-authored-by: Alex S <49695018+alexs-mparticle@users.noreply.github.com>
# [1.6.0](v1.5.0...v1.6.0) (2025-07-14) ### Bug Fixes * Prevent mutation of global launcherOptions during initialization ([#36](#36)) ([0f36fac](0f36fac)) ### Features * Add Extensions to Rokt Kit ([#26](#26)) ([73e9696](73e9696)) * Support adding identities to select placement attributes ([#35](#35)) ([f9595ea](f9595ea))
Summary
We want to add all user identities to the attributes that get passed to
selectPlacementsTesting Plan
Added unit tests. Tested in local app also.