Repository navigation
[pkgs/dash_analytics] Adding event for analyzer startup - #7
Conversation
| Future<Response>? sendEvent({ | ||
| required DashEvent eventName, | ||
| required Map<String, Object?> eventData, | ||
| Map<String, Object?> eventData, |
There was a problem hiding this comment.
Since we're removing required here, wouldn't that change the signature to Map<String, Object?>?? And / or need to assign a const default to eventData? I'm not sure why the analyzer isn't complaining here (or what I'm missing).
There was a problem hiding this comment.
Perhaps no default value is necessary if the method is abstract.
There was a problem hiding this comment.
It isn't actually going to be nullable, it will just default to an empty map in the implementation.
What would be best practice here, should I also include the default value in the abstract?
// OLD
/// API to send events to Google Analytics to track usage
Future<Response>? sendEvent({
required DashEvent eventName,
Map<String, Object?> eventData,
});
// NEW
/// API to send events to Google Analytics to track usage
Future<Response>? sendEvent({
required DashEvent eventName,
Map<String, Object?> eventData = const <String, Object?>{},
});Both approaches work in the example file
There was a problem hiding this comment.
I don't know that I have a strong opinion here; perhaps including it in the abstract method would help serve as documentation.
Also - I missed this in the initial review - but we should remove the always_specify_types types line from the analysis_options file (that lint generally goes counter to the dart style guide).
With that change, the above method sig can change to: Map<String, Object?> eventData = const {},.
There was a problem hiding this comment.
Ah makes sense, i'll remove that lint rule and update the abstract method to include the default value as well
| /// Officially-supported clients of this package. | ||
| /// | ||
| /// All [label] values should use a hyphen as a delimiter | ||
| /// All [label] values should use an underscore as a delimiter |
There was a problem hiding this comment.
👍 - I see there's a test to enforce this convention
| Future<Response>? sendEvent({ | ||
| required DashEvent eventName, | ||
| required Map<String, Object?> eventData, | ||
| Map<String, Object?> eventData, |
There was a problem hiding this comment.
I don't know that I have a strong opinion here; perhaps including it in the abstract method would help serve as documentation.
Also - I missed this in the initial review - but we should remove the always_specify_types types line from the analysis_options file (that lint generally goes counter to the dart style guide).
With that change, the above method sig can change to: Map<String, Object?> eventData = const {},.
Using this event to test that we are saving to the locally persisted log file