fix(analytics, android, ios): cast item INDEX param to integer#8964
Open
brojor wants to merge 1 commit intoinvertase:mainfrom
Open
fix(analytics, android, ios): cast item INDEX param to integer#8964brojor wants to merge 1 commit intoinvertase:mainfrom
brojor wants to merge 1 commit intoinvertase:mainfrom
Conversation
The React Native bridge converts all JS numbers to double, but the native Firebase SDK expects FirebaseAnalytics.Param.INDEX as an integer/long. When a double is passed, Firebase does not recognise it as the standard ecommerce parameter and item_list_index ends up as (not set) in GA4 / BigQuery. Mirror the existing QUANTITY conversion for INDEX in both native modules so that JS numbers are coerced to integer before being forwarded to Firebase.
|
@brojor is attempting to deploy a commit to the Invertase Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Code Review
This pull request adds support for the INDEX parameter in Firebase Analytics for both Android and iOS platforms. On Android, the parameter is converted from a double to a long, while on iOS, it is converted to an integer. A review comment suggests improving variable naming for better readability and notes a potential inconsistency in how numeric parameters are typed compared to the Firebase SDK expectations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The React Native bridge converts all JS numbers to
double, but the native Firebase SDK expectsFirebaseAnalytics.Param.INDEX(which maps toitem_list_index) as an integer/long. When adoubleis forwarded, Firebase does not recognise it as the standard ecommerce parameter —item_list_indexends up as(not set)in GA4 / BigQuery, breaking attribution of clicks/views to list positions.The library already handles this exact problem for
Param.QUANTITYin both native modules. This PR mirrors that conversion forParam.INDEX:ReactNativeFirebaseAnalyticsModule.java):putLong(FirebaseAnalytics.Param.INDEX, (long) number)RNFBAnalyticsModule.m):item[kFIRParameterIndex] = @([item[kFIRParameterIndex] integerValue])No JS / TS changes — the public API already accepts
index: number, only the native coercion was missing.Related issues
None filed upstream; happy to open one if preferred.
Release Summary
Fix
item_list_indexshowing as(not set)in GA4 / BigQuery whenindexis provided onitems[].Checklist
AndroidiOSOther(macOS, web)e2etests added or updated inpackages/**/e2ejesttests added or updated inpackages/**/__tests__No tests added — the existing
QUANTITYconversion (the precedent this PR follows) is also not covered by jest/e2e tests, since the coercion happens in the native modules below the JS bridge and there is no native test infra in the analytics package. Happy to add coverage if maintainers point me at the right place.Test Plan
Verified in production via `patch-package` against `@react-native-firebase/analytics@22.3.0` in a live e-commerce app:
🔥
Note
Low Risk
Small, localized change to native parameter coercion for analytics events; low risk aside from potential truncation if callers pass non-integer
indexvalues.Overview
Ensures Firebase ecommerce
items[]event params sendINDEX/item_list_indexas an integer type instead of a JS-bridgedouble.On Android,
ReactNativeFirebaseAnalyticsModule.toBundlenow castsFirebaseAnalytics.Param.INDEXtolong; on iOS,cleanJavascriptParamsnow coerceskFIRParameterIndexto anintegerValue, mirroring existingQUANTITYhandling.Reviewed by Cursor Bugbot for commit 77c898a. Bugbot is set up for automated code reviews on this repo. Configure here.