Skip to content

Conversation

@osilviotti
Copy link
Contributor

Summary

Setting identities through the mParticle module running on iOS resulted in those identities not being passed through to the mParticle dashboard. This is down to a mismatch between the codegen spec and the iOS implementation:

export type IdentityRequest = { [key: number]: string };

- (MPIdentityApiRequest *)MPIdentityApiRequestFromDict:(NSDictionary *)dict {
if ([dict isKindOfClass:MPIdentityApiRequest.class]) {
return (MPIdentityApiRequest*)dict;
}
MPIdentityApiRequest *request = [MPIdentityApiRequest requestWithEmptyUser];
if (dict[@"userIdentities"] && dict[@"userIdentities"] != [NSNull null]) {
NSDictionary *identities = dict[@"userIdentities"];
for (NSString *key in identities) {
MPIdentity identityType = (MPIdentity)[key integerValue];
NSString *value = identities[key];
[request setIdentity:value identityType:identityType];
}
}
if (dict[@"customerId"] && dict[@"customerId"] != [NSNull null]) {
request.customerId = dict[@"customerId"];
}
if (dict[@"email"] && dict[@"email"] != [NSNull null]) {
request.email = dict[@"email"];
}
return request;
}

and

+ (MPIdentityApiRequest *)MPIdentityApiRequest:(id)json {
NSDictionary *dict = json;
MPIdentityApiRequest *request = [MPIdentityApiRequest requestWithEmptyUser];
if (dict[@"userIdentities"] && dict[@"userIdentities"] != [NSNull null]) {
NSDictionary *identities = dict[@"userIdentities"];
for (NSString *key in identities) {
MPIdentity identityType = (MPIdentity)[key integerValue];
NSString *value = identities[key];
[request setIdentity:value identityType:identityType];
}
}
if (dict[@"customerId"] && dict[@"customerId"] != [NSNull null]) {
request.customerId = dict[@"customerId"];
}
if (dict[@"email"] && dict[@"email"] != [NSNull null]) {
request.email = dict[@"email"];
}
return request;
}

This PR removes the expectation that there will be a userIdentities dict in the identity request in the native iOS code and aligns its implementation with the interface described by the codegen spec

Copilot AI review requested due to automatic review settings September 2, 2025 13:06
@osilviotti osilviotti requested a review from a team as a code owner September 2, 2025 13:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a critical bug where user identities were not being passed through to the mParticle dashboard on iOS due to a mismatch between the codegen spec and native implementation. The fix removes the expectation of a nested userIdentities dictionary in favor of directly processing identity fields from the root dictionary.

  • Replaces nested userIdentities dictionary processing with direct dictionary iteration
  • Adds proper handling for email, customerId, and numeric identity types
  • Implements consistent logic across two similar methods in the codebase

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.

LGTM

@BrandonStalnaker BrandonStalnaker merged commit ebd6e7d into mParticle:main Sep 4, 2025
7 of 8 checks passed
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.

3 participants