Skip to content
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 21 commits into from Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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 Sep 12, 2022
07bca4c
chore(in-app-messaging): update example app
russellwheatley Sep 12, 2022
c991ef2
feat(analytics): write tests and update event_parameters.dart
russellwheatley Sep 13, 2022
7a81816
feat(analytics): rm incorrect code
russellwheatley Sep 13, 2022
d85f8f4
feat(analytics): improve assertion message
russellwheatley Sep 13, 2022
281bf77
chore: analyze and formatting
russellwheatley Sep 13, 2022
a00eb9c
chore: analyze and formatting
russellwheatley Sep 13, 2022
aef5641
feat(analytics): update EventParameters API
russellwheatley Sep 14, 2022
4076b92
Merge branch 'master' into @russell/analytics-8861/2
russellwheatley Dec 8, 2022
dd00a27
update integration tests with new API
russellwheatley Dec 8, 2022
6ef36bf
feat(analytics): `setDefaultParameters()` uses `EventParameters` API
russellwheatley Dec 8, 2022
ab29980
feat(analytics): update event parameters
russellwheatley Dec 9, 2022
a67d312
feat(analytics, android): update int to long
russellwheatley Dec 9, 2022
fcbd3f8
feat(analytics): update docs
russellwheatley Dec 9, 2022
72e3e5e
feat(analytics): update inline docs
russellwheatley Dec 9, 2022
c7d1039
feat(analytics): update inline docs
russellwheatley Dec 9, 2022
cce45c7
Merge branch 'master' into @russell/analytics-8861/2
russellwheatley Dec 23, 2022
16f90f2
chore(analytics): revert changes to make it backwards compatible
russellwheatley Dec 23, 2022
8781763
test(analytics): assert exception for incorrect param
russellwheatley Dec 23, 2022
e832483
test(analytics): assert exception for incorrect param
russellwheatley Dec 23, 2022
e764349
chore(analytics): update comments
russellwheatley Dec 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -67,18 +67,18 @@ class _MyHomePageState extends State<MyHomePage> {
}

Future<void> _sendAnalyticsEvent() async {
EventParameters params = EventParameters();
Lyokone marked this conversation as resolved.
Show resolved Hide resolved

params.addParameter('string', string: 'string');
params.addParameter('int', number: 42);
params.addParameter('long', number: 12345678910);
params.addParameter('double', number: 42.0);
params.addParameter('bool', string: true.toString());
// 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
await widget.analytics.logEvent(
name: 'test_event',
parameters: <String, dynamic>{
'string': 'string',
'int': 42,
'long': 12345678910,
'double': 42.0,
// 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(),
Copy link

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 as value.toString()?

This way we might support most of these base types.

Copy link
Member Author

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.

'items': [itemCreator()]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have items anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for custom events (logEvent()). See the description for why 😄

},
parameters: params,
);
setMessage('logEvent succeeded');
}
Expand Down Expand Up @@ -156,6 +156,9 @@ class _MyHomePageState extends State<MyHomePage> {
}

Future<void> _testAllEventTypes() async {
EventParameters params =
EventParameters.fromMap({'foo': 403, 'bar': 'baz'});
await widget.analytics.logEvent(name: 'super_test', parameters: params);
await widget.analytics.logAddPaymentInfo();
await widget.analytics.logAddToCart(
currency: 'USD',
Expand Down
Expand Up @@ -58,15 +58,14 @@ void testsMain() {
promotionName: 'promotionName',
quantity: 1,
);

// test custom event
await expectLater(
analytics.logEvent(
name: 'testing-parameters',
parameters: {
'foo': 'bar',
'baz': 500,
'items': [analyticsEventItem],
},
parameters: EventParameters()
.addParameter('foo', string: 'bar')
.addParameter('bar', number: 500),
),
completes,
);
Expand Down
Expand Up @@ -11,6 +11,6 @@ import 'package:firebase_core_platform_interface/firebase_core_platform_interfac
show FirebasePluginPlatform;
import 'package:firebase_analytics_platform_interface/firebase_analytics_platform_interface.dart';
export 'package:firebase_analytics_platform_interface/firebase_analytics_platform_interface.dart'
show AnalyticsEventItem, AnalyticsCallOptions;
show AnalyticsEventItem, AnalyticsCallOptions, EventParameters;
export 'observer.dart';
part 'src/firebase_analytics.dart';