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
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,10 @@ - (NSMutableArray *)getParametersForProducts:(id)products {
if (product.price) {
[productParameters setObject:product.price forKey:kFIRParameterPrice];
}
if (product.position) {
id indexParameter = @(product.position);
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason you defined this as id instead of NSNumber * ?

Copy link
Contributor Author

@mmustafa-tse mmustafa-tse Apr 10, 2025

Choose a reason for hiding this comment

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

@BrandonStalnaker - it was throwing an error that I think it needs to be an id in order to pass
Screenshot 2025-04-10 at 6 22 56 AM

[productParameters setObject:indexParameter forKey:kFIRParameterIndex];
}
if (product.userDefinedAttributes) {
for (NSString *productCustomAttribute in product.userDefinedAttributes) {
[productParameters setObject:product.userDefinedAttributes[productCustomAttribute] forKey:productCustomAttribute];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ - (NSString *)standardizeValue:(id)value forEvent:(BOOL)forEvent;
- (NSString *)getEventNameForCommerceEvent:(MPCommerceEvent *)commerceEvent parameters:(NSDictionary<NSString *, id> *)parameters;
- (NSDictionary<NSString *, id> *)getParameterForCommerceEvent:(MPCommerceEvent *)commerceEvent;
- (NSMutableDictionary<NSString *, id> *)getParametersForScreen:(MPEvent *)screenEvent;
- (NSMutableArray *)getParametersForProducts:(id)products;
@end

@interface mParticle_Firebase_AnalyticsTests : XCTestCase
Expand Down Expand Up @@ -298,6 +299,7 @@ - (void)testProductParameters {
NSMutableDictionary<NSString *, id> *testProductCustomAttributes = [[@{@"productCustomAttribute": @"potato", @"store": @"Target"} mutableCopy] mutableCopy];
product.brand = @"LV";
product.category = @"vegetable";
product.position = 4;
product.userDefinedAttributes = testProductCustomAttributes;

MPCommerceEvent *event = [[MPCommerceEvent alloc] initWithImpressionName:@"suggested products list" product:product];
Expand All @@ -306,8 +308,8 @@ - (void)testProductParameters {
NSArray *itemsArray = [exampleKit getParametersForProducts:impressionProducts];
id item = itemsArray[0];

// The item inside itemsArray should include 8 parameters in total including the 2 product custom attributes
XCTAssertEqual([item count], 8);
// The item inside itemsArray should include 9 parameters in total including the 2 product custom attributes
XCTAssertEqual([item count], 9);
}

- (void)testCommerceEventCheckoutOptions {
Expand Down