disable Firebase Analytics on Linux and explicitly handle Unsupported…#2818
disable Firebase Analytics on Linux and explicitly handle Unsupported…#2818
Conversation
…Error in init * Add a `Platform.isLinux` guard to immediately disable analytics on unsupported platforms * Wrap `Firebase.initializeApp` in its own `try/catch` to catch `UnsupportedError` and short-circuit initialization * Complete the `_initCompleter` with an error on unsupported platforms to unblock awaiting callers * Preserve existing retry logic for other initialization failures without retrying when unsupported * Log debug messages when initialization is skipped or fails due to lack of Linux support
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Visit the preview URL for this PR (updated for commit 9b1434e): https://walletrc--pull-2818-merge-vkvsg7rh.web.app (expires Wed, 02 Jul 2025 14:49:46 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc |
CharlVS
left a comment
There was a problem hiding this comment.
Thank you for your contributions.
| @@ -1,5 +1,6 @@ | |||
| import 'dart:convert'; | |||
| import 'dart:async'; | |||
| import 'dart:io'; | |||
There was a problem hiding this comment.
Please instead use TargetPlatform and kIsWeb from package:flutter/foundation.dart, similar to how it's done in lib/firebase_options.dart because dart:io isn't supported on web. I'm not sure why it builds and runs.
There was a problem hiding this comment.
Done in 9b1434e. Thanks for sharing best practices.
Removed import of dart:io and its `Platform.isLinux` check in AnalyticsRepo, switching to Flutter’s cross-platform API (`kIsWeb` + defaultTargetPlatform).
…Error in init
Platform.isLinuxguard to immediately disable analytics on unsupported platformsFirebase.initializeAppin its owntry/catchto catchUnsupportedErrorand short-circuit initialization_initCompleterwith an error on unsupported platforms to unblock awaiting callers