New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(firebase_analytics): update logEvent()
& setDefaultParameters()
to assert input types.
#9520
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
514ea81
feat(analytics): update logEvent so it can only accept strings and nums
russellwheatley 07bca4c
chore(in-app-messaging): update example app
russellwheatley c991ef2
feat(analytics): write tests and update event_parameters.dart
russellwheatley 7a81816
feat(analytics): rm incorrect code
russellwheatley d85f8f4
feat(analytics): improve assertion message
russellwheatley 281bf77
chore: analyze and formatting
russellwheatley a00eb9c
chore: analyze and formatting
russellwheatley aef5641
feat(analytics): update EventParameters API
russellwheatley 4076b92
Merge branch 'master' into @russell/analytics-8861/2
russellwheatley dd00a27
update integration tests with new API
russellwheatley 6ef36bf
feat(analytics): `setDefaultParameters()` uses `EventParameters` API
russellwheatley ab29980
feat(analytics): update event parameters
russellwheatley a67d312
feat(analytics, android): update int to long
russellwheatley fcbd3f8
feat(analytics): update docs
russellwheatley 72e3e5e
feat(analytics): update inline docs
russellwheatley c7d1039
feat(analytics): update inline docs
russellwheatley cce45c7
Merge branch 'master' into @russell/analytics-8861/2
russellwheatley 16f90f2
chore(analytics): revert changes to make it backwards compatible
russellwheatley 8781763
test(analytics): assert exception for incorrect param
russellwheatley e832483
test(analytics): assert exception for incorrect param
russellwheatley e764349
chore(analytics): update comments
russellwheatley File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import 'dart:async'; | |
|
||
import 'package:firebase_analytics/firebase_analytics.dart'; | ||
import 'package:firebase_core/firebase_core.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'firebase_options.dart'; | ||
|
@@ -68,7 +69,28 @@ class _MyHomePageState extends State<MyHomePage> { | |
}); | ||
} | ||
|
||
Future<void> _setDefaultEventParameters() async { | ||
if (kIsWeb) { | ||
setMessage( | ||
'"setDefaultEventParameters()" is not supported on web platform', | ||
); | ||
} else { | ||
// Only strings, numbers & null (longs & doubles for android, ints and doubles for iOS) are supported for default event parameters: | ||
await widget.analytics.setDefaultEventParameters(<String, dynamic>{ | ||
'string': 'string', | ||
'int': 42, | ||
'long': 12345678910, | ||
'double': 42.0, | ||
'bool': true.toString(), | ||
}); | ||
setMessage('setDefaultEventParameters succeeded'); | ||
} | ||
} | ||
|
||
Future<void> _sendAnalyticsEvent() async { | ||
// Only strings and numbers (longs & doubles for android, ints and doubles for iOS) are supported for GA custom event parameters: | ||
// https://firebase.google.com/docs/reference/ios/firebaseanalytics/api/reference/Classes/FIRAnalytics#+logeventwithname:parameters: | ||
// https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics#public-void-logevent-string-name,-bundle-params | ||
await widget.analytics.logEvent( | ||
name: 'test_event', | ||
parameters: <String, dynamic>{ | ||
|
@@ -79,9 +101,9 @@ class _MyHomePageState extends State<MyHomePage> { | |
// Only strings and numbers (ints & doubles) are supported for GA custom event parameters: | ||
// https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets#overview | ||
'bool': true.toString(), | ||
'items': [itemCreator()] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have items anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not for custom events ( |
||
}, | ||
); | ||
|
||
setMessage('logEvent succeeded'); | ||
} | ||
|
||
|
@@ -327,6 +349,10 @@ class _MyHomePageState extends State<MyHomePage> { | |
onPressed: _testResetAnalyticsData, | ||
child: const Text('Test resetAnalyticsData'), | ||
), | ||
MaterialButton( | ||
onPressed: _setDefaultEventParameters, | ||
child: const Text('Test setDefaultEventParameters'), | ||
), | ||
Text( | ||
_message, | ||
style: const TextStyle(color: Color.fromARGB(255, 0, 155, 0)), | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about to introduce an
addBool
method, which behind the scenes saves it asvalue.toString()
?This way we might support most of these base types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not as it isn't stored as a boolean and hence misleading,
true.toString()
is painless enough.