@@ -506,54 +506,9 @@ - (NSString *)getEventNameForCommerceEvent:(MPCommerceEvent *)commerceEvent para
506
506
return parameters;
507
507
}
508
508
509
- - (NSDictionary <NSString *, id> *)getParameterForImpression : (NSString *)impressionKey commerceEvent : (MPCommerceEvent *)commerceEvent products : (NSSet <MPProduct *> *)products {
510
- NSMutableDictionary <NSString *, id > *parameters = [[self standardizeValues: commerceEvent.customAttributes forEvent: YES ] mutableCopy ];
511
-
512
- [parameters setObject: impressionKey forKey: kFIRParameterItemListID ];
513
- [parameters setObject: impressionKey forKey: kFIRParameterItemListName ];
514
-
515
- if (products.count > 0 ) {
516
- NSMutableArray *itemArray = [[NSMutableArray alloc ] init ];
517
- for (MPProduct *product in products) {
518
- NSMutableDictionary <NSString *, id > *productParameters = [[NSMutableDictionary alloc ] init ];
519
-
520
- if (product.quantity ) {
521
- [productParameters setObject: product.quantity forKey: kFIRParameterQuantity ];
522
- }
523
- if (product.sku ) {
524
- [productParameters setObject: product.sku forKey: kFIRParameterItemID ];
525
- }
526
- if (product.name ) {
527
- [productParameters setObject: product.name forKey: kFIRParameterItemName ];
528
- }
529
- if (product.category ) {
530
- [productParameters setObject: product.category forKey: kFIRParameterItemCategory ];
531
- }
532
- if (product.brand ) {
533
- [productParameters setObject: product.brand forKey: kFIRParameterItemBrand ];
534
- }
535
- if (product.price ) {
536
- [productParameters setObject: product.price forKey: kFIRParameterPrice ];
537
- }
538
-
539
- [self limitDictionary: productParameters maxCount: FIR_MAX_ITEM_PARAMETERS];
540
- [itemArray addObject: productParameters];
541
- }
542
-
543
- if (itemArray.count > 0 ) {
544
- [parameters setObject: itemArray forKey: kFIRParameterItems ];
545
- }
546
- }
547
-
548
- [self limitDictionary: parameters maxCount: FIR_MAX_EVENT_PARAMETERS_PROPERTIES];
549
- return parameters;
550
- }
551
-
552
- - (NSDictionary <NSString *, id> *)getParameterForCommerceEvent : (MPCommerceEvent *)commerceEvent {
553
- NSMutableDictionary <NSString *, id > *parameters = [[self standardizeValues: commerceEvent.customAttributes forEvent: YES ] mutableCopy ];
554
-
509
+ - (NSMutableArray *)getParametersForProducts : (id )products {
555
510
NSMutableArray *itemArray = [[NSMutableArray alloc ] init ];
556
- for (MPProduct *product in commerceEvent. products ) {
511
+ for (MPProduct *product in products) {
557
512
NSMutableDictionary <NSString *, id > *productParameters = [[NSMutableDictionary alloc ] init ];
558
513
559
514
if (product.quantity ) {
@@ -574,11 +529,42 @@ - (NSString *)getEventNameForCommerceEvent:(MPCommerceEvent *)commerceEvent para
574
529
if (product.price ) {
575
530
[productParameters setObject: product.price forKey: kFIRParameterPrice ];
576
531
}
532
+ if (product.userDefinedAttributes ) {
533
+ for (NSString *productCustomAttribute in product.userDefinedAttributes ) {
534
+ [productParameters setObject: product.userDefinedAttributes[productCustomAttribute] forKey: productCustomAttribute];
535
+ }
536
+ }
577
537
578
538
[self limitDictionary: productParameters maxCount: FIR_MAX_ITEM_PARAMETERS];
579
539
[itemArray addObject: productParameters];
580
540
}
581
541
542
+ return itemArray;
543
+ }
544
+
545
+ - (NSDictionary <NSString *, id> *)getParameterForImpression : (NSString *)impressionKey commerceEvent : (MPCommerceEvent *)commerceEvent products : (NSSet <MPProduct *> *)products {
546
+ NSMutableDictionary <NSString *, id > *parameters = [[self standardizeValues: commerceEvent.customAttributes forEvent: YES ] mutableCopy ];
547
+
548
+ [parameters setObject: impressionKey forKey: kFIRParameterItemListID ];
549
+ [parameters setObject: impressionKey forKey: kFIRParameterItemListName ];
550
+
551
+ if (products.count > 0 ) {
552
+ NSMutableArray *itemArray = [self getParametersForProducts: products];
553
+
554
+ if (itemArray.count > 0 ) {
555
+ [parameters setObject: itemArray forKey: kFIRParameterItems ];
556
+ }
557
+ }
558
+
559
+ [self limitDictionary: parameters maxCount: FIR_MAX_EVENT_PARAMETERS_PROPERTIES];
560
+ return parameters;
561
+ }
562
+
563
+ - (NSDictionary <NSString *, id> *)getParameterForCommerceEvent : (MPCommerceEvent *)commerceEvent {
564
+ NSMutableDictionary <NSString *, id > *parameters = [[self standardizeValues: commerceEvent.customAttributes forEvent: YES ] mutableCopy ];
565
+
566
+ NSMutableArray *itemArray = [self getParametersForProducts: commerceEvent.products];
567
+
582
568
if (itemArray.count > 0 ) {
583
569
[parameters setObject: itemArray forKey: kFIRParameterItems ];
584
570
}
0 commit comments