feat(MSDK-3794): Add Firebase mediation integration to React Native sample app#210
Conversation
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
📝 WalkthroughWalkthroughThis PR equips the Usercentrics React Native SDK sample app with Firebase Analytics integration and consent mediation capabilities. Android and iOS build configurations add Google Services plugins and Firebase dependencies. The Usercentrics SDK is initialized with a mediation flag and debug logging. The Home screen checks consent status at mount time, displays consent layers, and handles responses. Comprehensive documentation covers platform-specific setup, mediation testing, and troubleshooting. ChangesFirebase Integration and Consent Mediation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review Summary by QodoAdd Firebase mediation integration and comprehensive documentation to React Native sample app
WalkthroughsDescription• Integrates Firebase Analytics as mediation partner on Android and iOS • Moves SDK configuration to App.tsx with mediation mode toggle flag • Adds automatic consent status check on HomeScreen mount • Updates bundle ID to com.usercentrics.sdk.mediation.test • Completely rewrites README with comprehensive setup and usage guide Diagramflowchart LR
A["App.tsx<br/>SDK Config"] -->|"MEDIATION_TEST_ENABLED"| B["Firebase<br/>Integration"]
A -->|"SETTINGS_ID"| C["Usercentrics<br/>Configuration"]
D["HomeScreen"] -->|"useEffect"| E["Usercentrics.status()"]
E -->|"shouldCollectConsent"| F["Show Banner"]
E -->|"existing consents"| G["Apply Consent"]
H["Android Setup<br/>google-services plugin"] --> B
I["iOS Setup<br/>FirebaseApp.configure"] --> B
B -->|"mediation"| J["Consent Propagation"]
File Changes1. sample/android/app/build.gradle.kts
|
Code Review by Qodo
1.
|
|
PR Summary: Adds Firebase consent-mediation to the React Native sample app: integrates Firebase Analytics as a mediation partner, wires native Firebase setup, enables consent mediation in the JS SDK, and updates docs and sample flows. Key changes:
Potential breaking / noteworthy items:
|
|
Reviewed up to commit:554c528c94b959340a0bb05229fbbb9dbdfde5cf |
|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (3)
sample/android/app/build.gradle.kts (1)
83-84: ⚡ Quick winFirebase BOM
33.13.0is several major releases behind the current34.12.0.The Firebase Android BoM has been updated to v34.1.0 (and subsequently to 34.12.0). As a sample app this is lower risk, but staying on
33.xmeans missing security patches and behavioural fixes in Analytics. Consider bumping to the latest BOM before publishing.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sample/android/app/build.gradle.kts` around lines 83 - 84, Update the Firebase BoM version used in the Gradle dependencies: find the implementation(platform("com.google.firebase:firebase-bom:33.13.0")) line and replace the BOM version with the current release (e.g., 34.12.0) so the implementation("com.google.firebase:firebase-analytics") dependency picks up the latest matching Firebase artifact versions; ensure you run a build to verify compatibility and adjust any downstream Firebase dependency versions if needed.sample/android/build.gradle.kts (1)
10-10: ⚡ Quick winMove
google-servicesversion to the Gradle version catalog for consistency.The google-services plugin at
4.4.2is two patch versions behind the current4.4.4. More importantly, this dependency uses a hardcoded version string while the other Gradle plugins (lines 7–9) reference versions from the catalog. Addgoogle-services = "4.4.4"togradle/libs.versions.tomland update line 10 to useclasspath(versions.google.services).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sample/android/build.gradle.kts` at line 10, Add a new entry in the Gradle version catalog (gradle/libs.versions.toml) like google-services = "4.4.4" and replace the hardcoded plugin declaration classpath("com.google.gms:google-services:4.4.2") in build.gradle.kts with the catalog reference using versions.google.services so the google‑services plugin uses the centralized version; ensure you reference the exact key "google-services" in the catalog and "versions.google.services" in the classpath call.sample/ios/Podfile (1)
27-27: ⚡ Quick winPin
FirebaseAnalyticsto a specific version for reproducible builds.Without a version constraint,
pod installcan silently resolve to a new major/minor release that breaks the Firebase ↔ Usercentrics mediation integration. Consider locking to the version in use (or at least a compatible range).♻️ Proposed fix
- pod 'FirebaseAnalytics' + pod 'FirebaseAnalytics', '~> 11.0' # pin to the major in use; update alongside Firebase BOM on Android🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sample/ios/Podfile` at line 27, Pin the FirebaseAnalytics pod to a specific version or a constrained version range in the Podfile to ensure reproducible builds and avoid breaking changes; locate the pod declaration "pod 'FirebaseAnalytics'" and replace it with a fixed version specifier or compatible range (e.g., '= x.y.z' or '~> x.y') that matches the currently used Firebase Analytics release.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sample/android/settings.gradle.kts`:
- Line 18: The build currently calls mavenLocal() which can make CI builds
non-reproducible; remove that call from the settings.gradle.kts or wrap it in a
conditional that only enables local Maven resolution for developer machines
(e.g., check a Gradle project property or environment variable such as CI or a
custom property like useLocalMaven), add a short comment explaining why the
guard exists (only for local snapshot testing of react-native-usercentrics), and
ensure the unique symbol mavenLocal() is only executed when the guard permits so
CI and shared builds use only declared remote repositories.
In `@sample/ios/sample/GoogleService-Info.plist`:
- Around line 5-30: Replace all real Firebase values in GoogleService-Info.plist
(API_KEY, GCM_SENDER_ID, GOOGLE_APP_ID, DATABASE_URL, STORAGE_BUCKET, PROJECT_ID
and any other identifying entries) with descriptive placeholder strings (e.g.,
YOUR_FIREBASE_API_KEY, YOUR_GCM_SENDER_ID, YOUR_GOOGLE_APP_ID,
YOUR_DATABASE_URL, YOUR_STORAGE_BUCKET, YOUR_PROJECT_ID) and remove any live
project identifiers; then add concise setup instructions to sample/README.md
telling users to download their own GoogleService-Info.plist from the Firebase
Console and place it in the sample/ios/sample/ directory (or an equivalent path)
before running the sample.
In `@sample/README.md`:
- Around line 31-51: The fenced code block showing the project tree (the block
beginning with ``` and the "sample/" tree) is missing a language specifier;
update that opening fence to include a tag such as `text` or `plaintext` (e.g.,
change ``` to ```text) so markdownlint MD040 is satisfied and renderers get
syntax awareness for the tree block in README.md.
In `@sample/src/App.tsx`:
- Around line 7-9: The MEDIATION_TEST_ENABLED constant is set to true against
its comment and should be false for normal builds; change MEDIATION_TEST_ENABLED
to false. Replace the hardcoded live settings ID in SETTINGS_ID
('3C9-yvno8-dEzy') with a clear placeholder (e.g.,
'<YOUR_USERCENTRICS_SETTINGS_ID>') and update any README/setup docs to instruct
developers to provide their own ID and required Google service files when
enabling mediation mode. Ensure you only change the values of
MEDIATION_TEST_ENABLED and SETTINGS_ID in App.tsx.
In `@sample/src/screens/Home.tsx`:
- Around line 84-85: The onPress handlers call Usercentrics.status() and discard
its result and errors before calling navigation.navigate (see
Usercentrics.status and navigation.navigate inside the Button onPress
callbacks); either await and handle the result/error (e.g., wrap await
Usercentrics.status() in try/catch and only navigate on success or log/handle
failures) or remove the unnecessary await if you don't need a readiness barrier
— update both Button handlers (the async onPress functions) accordingly so
errors from Usercentrics.status() are not ignored.
- Around line 12-20: HomeScreen calls Usercentrics.status() before the SDK is
initialized in App (Usercentrics.configure()), causing race/unhandled-rejection
issues; hoist Usercentrics.configure() to module scope in App.tsx so it runs
synchronously before any components mount, and update the Home.tsx effect that
calls Usercentrics.status() to handle promise rejections (add a .catch() and
fail-safe branch) so errors from Usercentrics.status() cannot go unhandled.
---
Nitpick comments:
In `@sample/android/app/build.gradle.kts`:
- Around line 83-84: Update the Firebase BoM version used in the Gradle
dependencies: find the
implementation(platform("com.google.firebase:firebase-bom:33.13.0")) line and
replace the BOM version with the current release (e.g., 34.12.0) so the
implementation("com.google.firebase:firebase-analytics") dependency picks up the
latest matching Firebase artifact versions; ensure you run a build to verify
compatibility and adjust any downstream Firebase dependency versions if needed.
In `@sample/android/build.gradle.kts`:
- Line 10: Add a new entry in the Gradle version catalog
(gradle/libs.versions.toml) like google-services = "4.4.4" and replace the
hardcoded plugin declaration classpath("com.google.gms:google-services:4.4.2")
in build.gradle.kts with the catalog reference using versions.google.services so
the google‑services plugin uses the centralized version; ensure you reference
the exact key "google-services" in the catalog and "versions.google.services" in
the classpath call.
In `@sample/ios/Podfile`:
- Line 27: Pin the FirebaseAnalytics pod to a specific version or a constrained
version range in the Podfile to ensure reproducible builds and avoid breaking
changes; locate the pod declaration "pod 'FirebaseAnalytics'" and replace it
with a fixed version specifier or compatible range (e.g., '= x.y.z' or '~> x.y')
that matches the currently used Firebase Analytics release.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1180b34d-b563-4093-b52b-428095f65e69
⛔ Files ignored due to path filters (1)
sample/ios/Podfile.lockis excluded by!**/*.lock
📒 Files selected for processing (13)
sample/README.mdsample/android/app/build.gradle.ktssample/android/app/src/main/AndroidManifest.xmlsample/android/build.gradle.ktssample/android/settings.gradle.ktssample/ios/Podfilesample/ios/sample.xcodeproj/project.pbxprojsample/ios/sample/AppDelegate.swiftsample/ios/sample/GoogleService-Info.plistsample/ios/sample/Info.plistsample/ios/sample/PrivacyInfo.xcprivacysample/src/App.tsxsample/src/screens/Home.tsx
There was a problem hiding this comment.
♻️ Duplicate comments (1)
sample/README.md (1)
31-31:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAdd a language tag to the project-tree fenced block.
The code fence at Line 31 is missing a language specifier, which still triggers MD040.
Proposed fix
-``` +```text sample/ ├── src/ │ ├── App.tsx # SDK initialisation and navigation root🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sample/README.md` at line 31, The README's project-tree fenced code block (the triple-backtick block containing "sample/ ├── src/ ...") is missing a language tag which triggers MD040; update that fenced block declaration (the opening ``` line for the project-tree block) to include a language tag such as "text" or "bash" so the block becomes ```text (or another appropriate tag) to satisfy the linter and preserve formatting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@sample/README.md`:
- Line 31: The README's project-tree fenced code block (the triple-backtick
block containing "sample/ ├── src/ ...") is missing a language tag which
triggers MD040; update that fenced block declaration (the opening ``` line for
the project-tree block) to include a language tag such as "text" or "bash" so
the block becomes ```text (or another appropriate tag) to satisfy the linter and
preserve formatting.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ae249197-be56-4747-b649-b7a19292f597
📒 Files selected for processing (2)
sample/.gitignoresample/README.md
✅ Files skipped from review due to trivial changes (1)
- sample/.gitignore
|
CodeAnt AI is running the review. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Sequence DiagramThis PR centralizes Usercentrics SDK configuration (with mediation enabled) and adds an automatic consent status check on the home screen, so user choices drive both the in-app consent UI and Firebase Analytics tracking. sequenceDiagram
participant User
participant App
participant UsercentricsSDK
participant ConsentBanner
participant FirebaseAnalytics
App->>UsercentricsSDK: Configure with settingsId and consent mediation enabled
App->>UsercentricsSDK: Get consent status on home screen mount
UsercentricsSDK-->>App: Return consent status
alt Consent required
App->>ConsentBanner: Show first layer consent banner
User->>ConsentBanner: Choose consent options
ConsentBanner->>UsercentricsSDK: Submit user consent
else Consent already stored
App->>UsercentricsSDK: Apply existing consents
end
UsercentricsSDK->>FirebaseAnalytics: Update tracking according to consent
Generated by CodeAnt AI |
|
CodeAnt AI finished running the review. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
User description
PR description
Summary
Usercentrics.configure()intoApp.tsxviauseEffectwithMEDIATION_TEST_ENABLEDandSETTINGS_IDas the single control point formediation mode and settings configuration
Usercentrics.status()check onHomeScreenmount — shows firstlayer immediately if consent is required, otherwise applies existing consents
google-servicesplugin, Firebase BOM 33.13.0, all collectionflags disabled by default in
AndroidManifest.xmlFirebaseAnalyticspod,FirebaseApp.configure()inAppDelegate,FIREBASE_ANALYTICS_COLLECTION_ENABLED = falseinInfo.plist,PrivacyInfo.xcprivacyupdated with NSUserDefaults access reasonscom.usercentrics.sdk.mediation.testonboth platforms
sample/README.md— replaces the default RN boilerplate with afull guide covering prerequisites, project structure, screen descriptions,
run instructions, consent mediation setup, New Architecture toggle,
scripts reference, and troubleshooting
Summary by CodeRabbit
Documentation
New Features
Chores
CodeAnt-AI Description
Make Firebase consent mediation optional in the sample app
What Changed
Impact
✅ Safer local Firebase testing✅ Fewer accidental analytics collection events✅ Faster consent flow on app launch🔄 Retrigger CodeAnt AI Review
Details
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.