Skip to content

Commit

Permalink
fix: Preserve attributes when mapping commerce events
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjenkins committed Sep 2, 2021
1 parent b618e5b commit 0ff8414
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions UnitTests/MPKitContainerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1993,12 +1993,14 @@ - (void)testExpandedCommerceEventProjection {

MPProduct *product = [[MPProduct alloc] initWithName:@"product name" sku:@"product sku" quantity:@1 price:@45];
MPCommerceEvent *commerceEvent = [[MPCommerceEvent alloc] initWithAction:MPCommerceEventActionViewDetail product:product];
commerceEvent.customAttributes = @{ @"foo attr 1": @"foo attr value 1"};

MPKitRegister *kitRegister = [[MPKitRegister alloc] initWithName:@"AppsFlyer" className:@"MPKitAppsFlyerTest"];
MPKitFilter *kitFilter = [kitContainer filter:kitRegister forCommerceEvent:commerceEvent];

XCTAssert([kitFilter.forwardEvent isKindOfClass:[MPEvent class]]);
XCTAssertEqualObjects(((MPEvent *)kitFilter.forwardEvent).name, @"af_content_view");
XCTAssertEqualObjects(((MPEvent *)kitFilter.forwardEvent).customAttributes, @{ @"foo attr 1": @"foo attr value 1"});
}

- (void)testShouldDelayUploadMaxTime {
Expand Down
1 change: 1 addition & 0 deletions mParticle-Apple-SDK/Kits/MPKitContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,7 @@ - (void)project:(id<MPExtensionKitProtocol>)kitRegister commerceEvent:(MPCommerc
projectedCommerceEvents.push_back(projectedCommerceEvent);
} else {
MPEvent *projectedEvent = [[MPEvent alloc] initWithName:(eventProjection.projectedName ? : @" ") type:MPEventTypeTransaction];
projectedEvent.customAttributes = commerceEvent.customAttributes;
projectedEvents.push_back(projectedEvent);
}

Expand Down

0 comments on commit 0ff8414

Please sign in to comment.