Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(analytics): added missing quantity parameter to the Item structure #4536

Merged
merged 5 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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: 15 additions & 1 deletion packages/analytics/ios/RNFBAnalytics/RNFBAnalyticsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,21 @@ - (dispatch_queue_t)methodQueue {
rejecter:
(RCTPromiseRejectBlock) reject) {
@try {
[FIRAnalytics logEventWithName:name parameters:params];
if (params[kFIRParameterItems]) {
NSMutableDictionary *newParams = [params mutableCopy];
NSMutableArray *newItems = [NSMutableArray array];
[(NSArray *)params[kFIRParameterItems] enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSMutableDictionary *item = [obj mutableCopy];
if (item[kFIRParameterQuantity]) {
item[kFIRParameterQuantity] = @([item[kFIRParameterQuantity] integerValue]);
mikehardy marked this conversation as resolved.
Show resolved Hide resolved
}
[newItems addObject:[item copy]];
}];
newParams[kFIRParameterItems] = [newItems copy];
[FIRAnalytics logEventWithName:name parameters:[newParams copy]];
} else {
[FIRAnalytics logEventWithName:name parameters:params];
}
} @catch (NSException *exception) {
return [RNFBSharedUtils rejectPromiseWithExceptionDict:reject exception:exception];
}
Expand Down
5 changes: 5 additions & 0 deletions packages/analytics/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ export namespace FirebaseAnalyticsTypes {
* The Item variant.
*/
item_variant?: string;
/**
* The Item quantity.
*/
quantity?: number;
}

export interface AddPaymentInfoEventParameters {
items?: Item[];
/**
Expand Down
1 change: 1 addition & 0 deletions packages/analytics/lib/structs.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Item = struct({
item_list_name: 'string?',
item_location_id: 'string?',
item_variant: 'string?',
quantity: 'number?',
});

export const ScreenView = struct({
Expand Down