Closed yulkin2002 closed 3 years ago
@yulkin2002 Can you provide an entire minimal code sample that we can use to replicate this issue ? or also see if same error occurs using the plugin's official example.
@darshankawar Please see below and let me know if you need more info.
@yulkin2002 Thanks for the code sample. I tried it and do get an error while passing a function as a dynamic object to logEvent(). But in order to pass DateTime.now(), since it accepts a string, you'll need to convert it into a string first and then pass it. So you can do below which should work:
await widget.analytics.logEvent(
name: 'test_event',
parameters: {'time': DateTime.now().toUtc().toIso8601String()}
);
Closing this as not an issue. Above implementation should help you to answer and get rid of the exception. If you disagree, write in comments and I'll reopen it.
thank you, it works. It would be great if you could add this to documentation as right now there is no way of knowing that I need to pass a string instead of an Object for DateTime.
Bug report
Describe the bug I am trying to log a timestamp as a custom parameter with firebase analytics plugin, but whenever I call the logEvent method on it, I get an exception. This custom parameter also does not appear in my dashboard.
Steps to reproduce
Steps to reproduce the behavior:
await analytics.logEvent( name: 'talentListLoadStarted', parameters: {'time': DateTime.now()}, );
error log
``` `E/flutter (26632): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Invalid argument: Instance of 'DateTime' E/flutter (26632): #0 StandardMessageCodec.writeValue (package:flutter/src/services/message_codecs.dart:419:7) E/flutter (26632): #1 StandardMessageCodec.writeValue.Expected behavior
parameter is logged and appears in my Firebase Analytics dashboard
Sample project
Providing a minimal example project which demonstrates the bug in isolation from your main App greatly enhances the chance of a timely fix. Please link to the public repository URL.
Additional context
Add any other context about the problem here.
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 6.1.7601], locale en-CA) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [√] Chrome - develop for the web [√] Android Studio (version 4.1.0) [√] VS Code [√] Connected device (2 available) • No issues found! ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` Changing current working directory to: C:\Users\Yuliya\AndroidStudioProjects\nearby Dart SDK 2.13.4 Flutter SDK 2.2.3 nearby 1.0.0+1 dependencies: - cloud_firestore 2.4.0 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interf ace flutter meta] - cupertino_icons 1.0.3 - firebase_analytics 8.2.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta] - firebase_auth 3.0.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface fl utter meta] - firebase_core 1.4.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.1.1 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutte r stack_trace] - firebase_storage 10.0.1 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_stor age_web flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - font_awesome_flutter 9.1.0 [flutter] - geocoding 2.0.0 [flutter geocoding_platform_interface] - get 3.26.0 [flutter] - google_sign_in 5.0.5 [flutter google_sign_in_platform_interface google_sign_in_web meta] - http 0.13.3 [async http_parser meta path pedantic] - image_picker 0.7.5+4 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface image_picker_for_web] - mockito 5.0.12 [analyzer build code_builder collection dart_style matcher meta path source_gen test_api] - modal_progress_hud 0.1.3 [flutter] - path_provider 2.0.2 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windo ws] - proximity_hash 2.0.0 - url_launcher 6.0.9 [flutter meta url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web u rl_launcher_windows] dev dependencies: - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters char code collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] transitive dependencies: - _fe_analyzer_shared 22.0.0 [meta] - analyzer 1.7.1 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_sp an watcher yaml pedantic] - args 2.2.0 - async 2.6.1 [meta collection] - boolean_selector 2.1.0 [source_span string_scanner] - build 2.0.3 [analyzer async convert crypto glob logging meta path] - built_collection 5.1.0 - built_value 8.1.1 [built_collection collection fixnum meta] - characters 1.1.0 - charcode 1.2.0 - cli_util 0.3.3 [meta path] - clock 1.1.0 - cloud_firestore_platform_interface 5.3.0 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.3.0 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.1.0 [built_collection built_value collection matcher meta] - collection 1.15.0 - convert 3.0.1 [typed_data] - cross_file 0.3.1+4 [flutter meta] - crypto 3.0.1 [collection typed_data] - dart_style 2.0.3 [analyzer args path pub_semver source_span] - fake_async 1.2.0 [clock collection] - ffi 1.1.2 - file 6.1.2 [meta path] - firebase 9.0.1 [http http_parser js] - firebase_analytics_platform_interface 2.0.1 [flutter meta] - firebase_analytics_web 0.3.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta] - firebase_auth_platform_interface 6.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 3.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins htt p_parser intl js meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.1.0 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_platform_interface 4.0.0 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.0.0 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web _plugins http js meta] - fixnum 1.0.0 - flutter_plugin_android_lifecycle 2.0.2 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - geocoding_platform_interface 2.0.0 [flutter meta plugin_platform_interface] - glob 2.0.1 [async collection file path pedantic string_scanner] - google_sign_in_platform_interface 2.0.1 [flutter meta quiver] - google_sign_in_web 0.10.0 [google_sign_in_platform_interface flutter flutter_web_plugins meta js] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image_picker_for_web 2.1.1 [flutter flutter_web_plugins image_picker_platform_interface meta] - image_picker_platform_interface 2.2.0 [flutter http meta plugin_platform_interface cross_file] - intl 0.17.0 [clock path] - js 0.6.3 - logging 1.0.1 - matcher 0.12.10 [stack_trace] - meta 1.3.0 - package_config 2.0.0 [path] - path 1.8.0 - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 2.0.0 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.11.1 - platform 3.0.0 - plugin_platform_interface 2.0.1 [meta] - process 4.2.3 [file path platform] - pub_semver 2.0.0 [collection] - quiver 3.0.1 [matcher] - sky_engine 0.0.99 - source_gen 1.0.3 [analyzer async build dart_style glob meta path pedantic source_span yaml] - 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] - term_glyph 1.2.0 - test_api 0.3.0 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_gl yph matcher] - typed_data 1.3.0 [collection] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.4 [flutter plugin_platform_interface] - url_launcher_web 2.0.1 [flutter flutter_web_plugins meta url_launcher_platform_interface] - url_launcher_windows 2.0.0 [flutter] - vector_math 2.1.0 - watcher 1.0.0 [async path pedantic] - win32 2.2.5 [ffi] - xdg_directories 0.2.0 [meta path process] - yaml 3.1.0 [collection source_span string_scanner] ```