Skip to content

Commit 6d8adf9

Browse files
feat: Add custom attributes to commerce events (#24)
1 parent 25f1144 commit 6d8adf9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

mParticle-Google-Analytics-Firebase/MPKitFirebaseAnalytics.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ - (MPKitExecStatus *)routeCommerceEvent:(MPCommerceEvent *)commerceEvent {
116116
eventName = kFIREventViewPromotion;
117117
}
118118
for (MPPromotion *promotion in commerceEvent.promotionContainer.promotions) {
119-
parameters = [self getParameterForPromotionCommerceEvent:promotion];
119+
parameters = [self getParameterForPromotion:promotion commerceEvent:commerceEvent];
120120

121121
[FIRAnalytics logEventWithName:eventName parameters:parameters];
122122
}
123123
} else if (commerceEvent.impressions) {
124124
eventName = kFIREventViewItemList;
125125
for (NSString *impressionKey in commerceEvent.impressions) {
126-
parameters = [self getParameterForImpressionCommerceEvent:impressionKey products:commerceEvent.impressions[impressionKey]];
126+
parameters = [self getParameterForImpression:impressionKey commerceEvent:commerceEvent products:commerceEvent.impressions[impressionKey]];
127127

128128
[FIRAnalytics logEventWithName:eventName parameters:parameters];
129129
}
@@ -365,8 +365,9 @@ - (NSString *)getEventNameForCommerceEvent:(MPCommerceEvent *)commerceEvent para
365365
}
366366
}
367367

368-
- (NSDictionary<NSString *, id> *)getParameterForPromotionCommerceEvent:(MPPromotion *)promotion {
369-
NSMutableDictionary<NSString *, id> *parameters = [[NSMutableDictionary alloc] init];
368+
- (NSDictionary<NSString *, id> *)getParameterForPromotion:(MPPromotion *)promotion commerceEvent:(MPCommerceEvent *)commerceEvent {
369+
NSMutableDictionary<NSString *, id> *parameters = [[self standardizeValues:commerceEvent.customAttributes forEvent:YES] mutableCopy];
370+
370371

371372
if (promotion.promotionId) {
372373
[parameters setObject:promotion.promotionId forKey:kFIRParameterPromotionID];
@@ -384,8 +385,8 @@ - (NSString *)getEventNameForCommerceEvent:(MPCommerceEvent *)commerceEvent para
384385
return parameters;
385386
}
386387

387-
- (NSDictionary<NSString *, id> *)getParameterForImpressionCommerceEvent:(NSString *)impressionKey products:(NSSet<MPProduct *> *)products {
388-
NSMutableDictionary<NSString *, id> *parameters = [[NSMutableDictionary alloc] init];
388+
- (NSDictionary<NSString *, id> *)getParameterForImpression:(NSString *)impressionKey commerceEvent:(MPCommerceEvent *)commerceEvent products:(NSSet<MPProduct *> *)products {
389+
NSMutableDictionary<NSString *, id> *parameters = [[self standardizeValues:commerceEvent.customAttributes forEvent:YES] mutableCopy];
389390

390391
[parameters setObject:impressionKey forKey:kFIRParameterItemListID];
391392
[parameters setObject:impressionKey forKey:kFIRParameterItemListName];
@@ -423,7 +424,7 @@ - (NSString *)getEventNameForCommerceEvent:(MPCommerceEvent *)commerceEvent para
423424
}
424425

425426
- (NSDictionary<NSString *, id> *)getParameterForCommerceEvent:(MPCommerceEvent *)commerceEvent {
426-
NSMutableDictionary<NSString *, id> *parameters = [[NSMutableDictionary alloc] init];
427+
NSMutableDictionary<NSString *, id> *parameters = [[self standardizeValues:commerceEvent.customAttributes forEvent:YES] mutableCopy];
427428

428429
NSMutableArray *itemArray = [[NSMutableArray alloc] init];
429430
for (MPProduct *product in commerceEvent.products) {

0 commit comments

Comments
 (0)