Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions mParticle-Rokt/MPKitRokt.m
Original file line number Diff line number Diff line change
Expand Up @@ -334,22 +334,11 @@ + (void)addIdentityAttributes:(NSMutableDictionary<NSString *, NSString *> * _Nu

+ (void)handleHashedEmail:(NSMutableDictionary<NSString *, NSString *> * _Nullable)attributes {
NSString *emailKey = [MPKitRokt stringForIdentityType:MPIdentityEmail];
NSString *otherKey = [MPKitRokt stringForIdentityType:MPIdentityOther];
NSString *hashedEmailValue = attributes[@"emailsha256"];

// Remove email and other is hashed vlaue already set
// Remove email if hashed value set
if (hashedEmailValue != nil) {
[attributes removeObjectForKey:emailKey];
[attributes removeObjectForKey:otherKey];
}

NSString *otherValue = attributes[otherKey];

// Remove email and replace key on other if it's set
if (otherValue != nil) {
[attributes removeObjectForKey:emailKey];
attributes[@"emailsha256"] = otherValue;
[attributes removeObjectForKey:otherKey];
}
}

Expand Down Expand Up @@ -393,7 +382,8 @@ + (NSString *)stringForIdentityType:(MPIdentity)identityType {
return @"microsoft";

case MPIdentityOther:
return @"other";
// As of 7/30/2025, "MPIdentityOther" is used by Rokt customers to identify based off hashed email
return @"emailsha256";
Comment thread
rmi22186 marked this conversation as resolved.
Comment thread
BrandonStalnaker marked this conversation as resolved.

case MPIdentityTwitter:
return @"twitter";
Expand Down
20 changes: 11 additions & 9 deletions mParticle_RoktTests/mParticle_RoktTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ - (void)testAddIdentityAttributes {
XCTAssertEqualObjects(passedAttributes[@"facebookcustomaudienceid"], @"testCustomAudienceID");
XCTAssertEqualObjects(passedAttributes[@"google"], @"testGoogle");
XCTAssertEqualObjects(passedAttributes[@"microsoft"], @"testMicrosoft");
XCTAssertEqualObjects(passedAttributes[@"other"], @"testOther");
XCTAssertNil(passedAttributes[@"other"]);
XCTAssertEqualObjects(passedAttributes[@"emailsha256"], @"testOther");
XCTAssertEqualObjects(passedAttributes[@"twitter"], @"testTwitter");
XCTAssertEqualObjects(passedAttributes[@"yahoo"], @"testYahoo");
XCTAssertEqualObjects(passedAttributes[@"other2"], @"testOther2");
Expand Down Expand Up @@ -307,7 +308,8 @@ - (void)testAddIdentityAttributesWithExistingAttributes {
XCTAssertEqualObjects(passedAttributes[@"facebookcustomaudienceid"], @"testCustomAudienceID");
XCTAssertEqualObjects(passedAttributes[@"google"], @"testGoogle");
XCTAssertEqualObjects(passedAttributes[@"microsoft"], @"testMicrosoft");
XCTAssertEqualObjects(passedAttributes[@"other"], @"testOther");
XCTAssertNil(passedAttributes[@"other"]);
XCTAssertEqualObjects(passedAttributes[@"emailsha256"], @"testOther");
XCTAssertEqualObjects(passedAttributes[@"twitter"], @"testTwitter");
XCTAssertEqualObjects(passedAttributes[@"yahoo"], @"testYahoo");
XCTAssertEqualObjects(passedAttributes[@"other2"], @"testOther2");
Expand Down Expand Up @@ -504,24 +506,24 @@ - (void)testHandleHashedEmailOtherOverride {

[MPKitRokt handleHashedEmail:passedAttributes];

XCTAssertNil(passedAttributes[@"email"]);
XCTAssertNil(passedAttributes[@"other"]);
XCTAssertEqualObjects(passedAttributes[@"emailsha256"], @"test@gmail.com");
XCTAssertTrue(passedAttributes.allKeys.count == 1);
XCTAssertEqualObjects(passedAttributes[@"email"], @"foo@gmail.com");
XCTAssertEqualObjects(passedAttributes[@"other"], @"test@gmail.com");
Comment thread
BrandonStalnaker marked this conversation as resolved.
XCTAssertNil(passedAttributes[@"emailsha256"]);
XCTAssertTrue(passedAttributes.allKeys.count == 2);
}

- (void)testHandleHashedEmailHashedOverride {
NSMutableDictionary<NSString *, NSString *> *passedAttributes = [[NSMutableDictionary alloc] init];
[passedAttributes setObject:@"foo@gmail.com" forKey:@"email"];
[passedAttributes setObject:@"test@gmail.com" forKey:@"other"];
[passedAttributes setObject:@"foo-value" forKey:@"other"];
[passedAttributes setObject:@"test2@gmail.com" forKey:@"emailsha256"];

[MPKitRokt handleHashedEmail:passedAttributes];

XCTAssertNil(passedAttributes[@"email"]);
XCTAssertNil(passedAttributes[@"other"]);
XCTAssertEqualObjects(passedAttributes[@"other"], @"foo-value");
XCTAssertEqualObjects(passedAttributes[@"emailsha256"], @"test2@gmail.com");
XCTAssertTrue(passedAttributes.allKeys.count == 1);
XCTAssertTrue(passedAttributes.allKeys.count == 2);
}

- (void)testTransformValuesToString {
Expand Down
Loading