Skip to content

Comments

feat: Add user attribute mapping#343

Merged
BrandonStalnaker merged 4 commits intodevelopmentfrom
feat/SQDSDKS-7184-ua-mapping
Apr 10, 2025
Merged

feat: Add user attribute mapping#343
BrandonStalnaker merged 4 commits intodevelopmentfrom
feat/SQDSDKS-7184-ua-mapping

Conversation

@BrandonStalnaker
Copy link
Collaborator

Summary

  • Allows User Attribute Mapping via the Kit Container/Kit Configuration in the SDK.

Testing Plan

  • Tested locally and through unit tests. Also tested out unrelated functionality and confirmed in the live stream.

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

Co-authored-by: Robert Ing <ring@mparticle.com>
Comment on lines +170 to +182
NSMutableDictionary *mappedAttributes = attributes.mutableCopy;
for (NSDictionary<NSString *, NSString *> *map in attributeMap) {
NSString *mapFrom = map[@"map"];
NSString *mapTo = map[@"value"];
if (mappedAttributes[mapFrom]) {
NSString * value = mappedAttributes[mapFrom];
[mappedAttributes removeObjectForKey:mapFrom];
mappedAttributes[mapTo] = value;
}
}
for (NSString *key in mappedAttributes) {
[[MParticle sharedInstance].identity.currentUser setUserAttribute:key value:mappedAttributes[key]];
}
Copy link
Member

Choose a reason for hiding this comment

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

can this be DRYed up into a separate function so that it's called from both selectPlacements methods?

Comment on lines +184 to +206
dispatch_async(dispatch_get_main_queue(), ^{
// Forwarding call to kits
MPForwardQueueParameters *queueParameters = [[MPForwardQueueParameters alloc] init];
[queueParameters addParameter:identifier];
[queueParameters addParameter:mappedAttributes];
[queueParameters addParameter:nil];
[queueParameters addParameter:nil];
[queueParameters addParameter:nil];
[queueParameters addParameter:nil];
[queueParameters addParameter:nil];
[queueParameters addParameter:nil];

SEL roktSelector = @selector(executeWithViewName:attributes:placements:onLoad:onUnLoad:onShouldShowLoadingIndicator:onShouldHideLoadingIndicator:onEmbeddedSizeChange:filteredUser:);
[[MParticle sharedInstance].kitContainer_PRIVATE forwardSDKCall:roktSelector
event:nil
parameters:queueParameters
messageType:MPMessageTypeEvent
userInfo:nil
];
});
} else {
MPILogVerbose(@"[MParticle.Rokt selectPlacements:attributes:] not performed due to kit not being configured");
}
Copy link
Member

Choose a reason for hiding this comment

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

This can also be DRYed up with the method below using all arguments and just pass either 2, or all arguments to it.

OCMVerifyAll(mockContainer);
}

- (void)testSelectPlacementsSimpleWithMapping {
Copy link
Member

Choose a reason for hiding this comment

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

This test stubs the getRoktPlacementAttributes call.

Can you add a test for getRoktPlacementAttributes itself, using a config like the one you put in the chat. passing in "[{"jsmap":null,"map":"f.name","maptype":"UserAttributeClass.Name","value":"firstname"},{"jsmap":null,"map":"zip","maptype":"UserAttributeClass.Name","value":"billingzipcode"},{"jsmap":null,"map":"l.name","maptype":"UserAttributeClass.Name","value":"lastname"}]"

and expecting what you have in line 168 back?

(note that i copied and pasted what you had in #temp-rokt-client but updated the mapping from f.name --> firstname instead of email

@BrandonStalnaker BrandonStalnaker merged commit 50ce934 into development Apr 10, 2025
10 of 12 checks passed
@BrandonStalnaker BrandonStalnaker deleted the feat/SQDSDKS-7184-ua-mapping branch April 10, 2025 12:01
mparticle-automation added a commit that referenced this pull request Apr 24, 2025
# [8.30.0](v8.29.0...v8.30.0) (2025-04-24)

### Features

* Add disabledKits option to MParticleOptions ([#347](#347)) ([f708431](f708431))
* Add MPRoktEmbeddedView Class ([#345](#345)) ([f4fb946](f4fb946))
* Add user attribute mapping ([#343](#343)) ([50ce934](50ce934))
* Automatically include sandbox in MPRokt Attributes ([#344](#344)) ([bdf4280](bdf4280))
@mparticle-automation
Copy link
Contributor

🎉 This PR is included in version 8.30.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