feat: Add user attribute mapping#343
Conversation
Co-authored-by: Robert Ing <ring@mparticle.com>
| 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]]; | ||
| } |
There was a problem hiding this comment.
can this be DRYed up into a separate function so that it's called from both selectPlacements methods?
| 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"); | ||
| } |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
# [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))
|
🎉 This PR is included in version 8.30.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Testing Plan
Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)