firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.7k stars 3.97k forks source link

🐛 Firebase Analytics: UnimplementedError: setDefaultEventParameters() is not implemented #7521

Closed ted-marozzi closed 2 years ago

ted-marozzi commented 2 years ago

Bug report

Describe the bug The error

UnimplementedError: setDefaultEventParameters() is not implemented 

is thrown when called on web

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a firebase web app with analytics
  2. Call the method FirebaseAnalytics.instance.setDefaultEventParameters({"version":"1.0.0"});
  3. See error thrown in console.

Expected behavior

Error is not thrown in console.

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand PS C:\GitHub\stockpile> flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.22000.318], locale en-AU) [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [√] Chrome - develop for the web [√] Android Studio (version 2020.3) [√] VS Code (version 1.62.3) [√] Connected device (2 available) • No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand PS C:\GitHub\stockpile> flutter pub deps -- --style=compact Dart SDK 2.14.4 Flutter SDK 2.5.3 stockpile 1.0.15 dependencies: - firebase_analytics 9.0.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_core 1.10.3 [firebase_core_platform_interface firebase_core_web flutter meta] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math] - google_fonts 2.1.0 [flutter http path_provider crypto] - logging 1.0.2 - package_info_plus 1.3.0 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web] dev dependencies: - cider 0.1.0 [args change klizma intl markdown marker path pub_semver version_manipulation yaml rfc_6901 pubspec_parse] - flutter_launcher_icons 0.9.2 [args image path yaml] - flutter_lints 1.0.4 [lints] - flutter_native_splash 1.3.2 [args image meta path xml yaml universal_io] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] - integration_test 0.0.0 [flutter flutter_driver flutter_test path vm_service archive async boolean_selector characters charcode clock collection crypto fake_async file matcher meta source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math webdriver] transitive dependencies: - archive 3.1.2 [crypto path] - args 2.3.0 - async 2.8.1 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - change 0.3.0 [markdown marker pub_semver intl] - characters 1.1.0 - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - clock 1.1.0 - collection 1.15.0 - crypto 3.0.1 [collection typed_data] - fake_async 1.2.0 [clock collection] - ffi 1.1.2 - file 6.1.2 [meta path] - firebase_analytics_platform_interface 3.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.4.0 [firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_core_platform_interface 4.2.0 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.5.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - flutter_driver 0.0.0 [file flutter flutter_test fuchsia_remote_debug_protocol path meta vm_service webdriver archive async boolean_selector characters charcode clock collection crypto matcher platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform] - http 0.13.4 [async http_parser meta path] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image 3.1.0 [archive meta xml] - intl 0.17.0 [clock path] - js 0.6.3 - json_annotation 4.4.0 [meta] - klizma 0.2.0 - lints 1.0.1 - markdown 4.0.1 [args charcode meta] - marker 0.2.2 [markdown] - matcher 0.12.10 [stack_trace] - meta 1.7.0 - package_info_plus_linux 1.0.3 [package_info_plus_platform_interface flutter path] - package_info_plus_macos 1.3.0 [flutter] - package_info_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface] - package_info_plus_web 1.0.4 [flutter flutter_web_plugins http meta package_info_plus_platform_interface] - package_info_plus_windows 1.0.4 [package_info_plus_platform_interface ffi flutter win32] - path 1.8.0 - path_provider 2.0.7 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - path_provider_android 2.0.9 [flutter path_provider_platform_interface] - path_provider_ios 2.0.7 [flutter path_provider_platform_interface] - path_provider_linux 2.1.2 [flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.4 [flutter meta path_provider_platform_interface] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.4 [ffi flutter meta path path_provider_platform_interface win32] - petitparser 4.4.0 [meta] - platform 3.0.0 - plugin_platform_interface 2.0.2 [meta] - process 4.2.3 [file path platform] - pub_semver 2.1.0 [collection meta] - pubspec_parse 1.2.0 [checked_yaml collection json_annotation pub_semver yaml] - rfc_6901 0.1.0 - sky_engine 0.0.99 - source_span 1.8.1 [collection path term_glyph] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.0 [charcode source_span] - sync_http 0.3.0 - term_glyph 1.2.0 - test_api 0.4.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - typed_data 1.3.0 [collection] - universal_io 2.0.4 [collection crypto meta typed_data] - vector_math 2.1.0 - version_manipulation 0.1.0 [pub_semver] - vm_service 7.1.1 - webdriver 3.0.0 [archive matcher path stack_trace sync_http] - win32 2.3.1 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.3.1 [collection meta petitparser] - yaml 3.1.0 [collection source_span string_scanner]

darshankawar commented 2 years ago

Checked on latest master wherein, I don't get the said log, but getting the same on latest stable:

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  FirebaseAnalytics.instance.setDefaultEventParameters({"version":"1.0.0"});
  await Firebase.initializeApp(
console error log ``` Error: UnimplementedError: setDefaultEventParameters() is not implemented at Object.throw_ [as throw] (http://localhost:53138/dart_sdk.js:5063:11) at firebase_analytics_web.FirebaseAnalyticsWeb.new.setDefaultEventParameters (http://localhost:53138/packages/firebase_analytics_platform_interface/src/platform_interface/platform_interface_firebase_analytics.dart.lib.js:131:17) at firebase_analytics.FirebaseAnalytics.__.setDefaultEventParameters (http://localhost:53138/packages/firebase_analytics/firebase_analytics.dart.lib.js:118:31) at setDefaultEventParameters.next () at runBody (http://localhost:53138/dart_sdk.js:40211:34) at Object._async [as async] (http://localhost:53138/dart_sdk.js:40242:7) at firebase_analytics.FirebaseAnalytics.__.setDefaultEventParameters (http://localhost:53138/packages/firebase_analytics/firebase_analytics.dart.lib.js:117:20) at main (http://localhost:53138/packages/triage/main.dart.lib.js:818:53) at main.next () at runBody (http://localhost:53138/dart_sdk.js:40211:34) at Object._async [as async] (http://localhost:53138/dart_sdk.js:40242:7) at main$ (http://localhost:53138/packages/triage/main.dart.lib.js:816:18) at main (http://localhost:53138/web_entrypoint.dart.lib.js:37:29) at main.next () at http://localhost:53138/dart_sdk.js:40192:33 at _RootZone.runUnary (http://localhost:53138/dart_sdk.js:40062:59) at _FutureListener.thenAwait.handleValue (http://localhost:53138/dart_sdk.js:34983:29) at handleValueCallback (http://localhost:53138/dart_sdk.js:35551:49) at Function._propagateToListeners (http://localhost:53138/dart_sdk.js:35589:17) at _Future.new.[_completeWithValue] (http://localhost:53138/dart_sdk.js:35437:23) at http://localhost:53138/dart_sdk.js:34617:46 at _RootZone.runUnary (http://localhost:53138/dart_sdk.js:40062:59) at _FutureListener.then.handleValue (http://localhost:53138/dart_sdk.js:34983:29) at handleValueCallback (http://localhost:53138/dart_sdk.js:35551:49) at Function._propagateToListeners (http://localhost:53138/dart_sdk.js:35589:17) at _Future.new.[_completeWithValue] (http://localhost:53138/dart_sdk.js:35437:23) at async._AsyncCallbackEntry.new.callback (http://localhost:53138/dart_sdk.js:35458:35) at Object._microtaskLoop (http://localhost:53138/dart_sdk.js:40330:13) at _startMicrotaskLoop (http://localhost:53138/dart_sdk.js:40336:13) at http://localhost:53138/dart_sdk.js:35811:9 ```
stable flutter doctor -v ``` [✓] Flutter (Channel stable, 2.8.0, on Mac OS X 10.15.4 19E2269 darwin-x64, locale en-GB) • Flutter version 2.8.0 at /Users/dhs/documents/fluttersdk/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision cf44000065 (10 hours ago), 2021-12-08 14:06:50 -0800 • Engine revision 40a99c5951 • Dart version 2.15.0 [✓] Android toolchain - develop for Android devices (Android SDK version 30) • Android SDK at /Users/dhs/Library/Android/sdk • Platform android-30, build-tools 30.0.3 • ANDROID_HOME = /Users/dhs/Library/Android/sdk • Java binary at: /Users/dhs/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.3, Build version 12C33 • CocoaPods version 1.10.1 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.1) • Android Studio at /Users/dhs/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) [✓] VS Code (version 1.57.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (4 available) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.82 • No issues found! ```
Salakar commented 2 years ago

Checked on latest master wherein, I don't get the said log, but getting the same on latest stable:

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  FirebaseAnalytics.instance.setDefaultEventParameters({"version":"1.0.0"});
  await Firebase.initializeApp(

console error log stable flutter doctor -v

It happens on web - but this is intended since this method is not supported on web - we're sorting a PR to make the error message more explicitly say it's not supported on web - but for this issue I'd say it's working as intended

ted-marozzi commented 2 years ago

Would be good to suggest that in the docs: https://firebase.flutter.dev/docs/analytics/usage#default-parameters

Can I ask why is it not supported? Is there a fundamental reason or is it just yet to be implemented?

Thanks for your time.

russellwheatley commented 2 years ago

@ted-marozzi It's not supported by the underlying web firebase-js -sdk. Will update documentation as you suggested.

ted-marozzi commented 2 years ago

For anyone that arrives here wanting this feature, I opened an issue on the firebase-js-sdk which you can thumbs up.