Skip to content
Open
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 @@ -211,6 +211,10 @@ private Bundle toBundle(ReadableMap readableMap) {
double number = itemBundle.getDouble(FirebaseAnalytics.Param.QUANTITY);
itemBundle.putInt(FirebaseAnalytics.Param.QUANTITY, (int) number);
}
if (itemBundle.containsKey(FirebaseAnalytics.Param.INDEX)) {
double number = itemBundle.getDouble(FirebaseAnalytics.Param.INDEX);
itemBundle.putLong(FirebaseAnalytics.Param.INDEX, (long) number);
}
Comment on lines +214 to +217
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There's an inconsistency in how numeric parameters are handled. The existing code for QUANTITY uses putInt, while this change uses putLong for INDEX. According to the Firebase SDK documentation, both parameters are expected to be of type long. For correctness and consistency, QUANTITY should also be handled as a long.

Additionally, using a more descriptive variable name instead of number would improve readability.

Suggested change
if (itemBundle.containsKey(FirebaseAnalytics.Param.INDEX)) {
double number = itemBundle.getDouble(FirebaseAnalytics.Param.INDEX);
itemBundle.putLong(FirebaseAnalytics.Param.INDEX, (long) number);
}
if (itemBundle.containsKey(FirebaseAnalytics.Param.INDEX)) {
double index = itemBundle.getDouble(FirebaseAnalytics.Param.INDEX);
itemBundle.putLong(FirebaseAnalytics.Param.INDEX, (long) index);
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Regarding the QUANTITY inconsistency — I'd prefer to keep that out of this PR to stay focused on the INDEX fix. If QUANTITY should indeed be a long per the Firebase SDK, that's a pre-existing issue and deserves its own PR so it can be reviewed and reverted independently.

For the variable naming, I intentionally kept number to stay consistent with the existing QUANTITY block right above, which uses the same pattern. Renaming only the new lines would introduce inconsistency within the same method.

validBundles.add(itemBundle);
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/analytics/ios/RNFBAnalytics/RNFBAnalyticsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ - (NSDictionary *)cleanJavascriptParams:(NSDictionary *)params {
if (item[kFIRParameterQuantity]) {
item[kFIRParameterQuantity] = @([item[kFIRParameterQuantity] integerValue]);
}
if (item[kFIRParameterIndex]) {
item[kFIRParameterIndex] = @([item[kFIRParameterIndex] integerValue]);
}
[newItems addObject:[item copy]];
}];
newParams[kFIRParameterItems] = [newItems copy];
Expand Down
Loading