Inject Usage dependency into FallbackDiscovery and BuildEvent (#53443)
* Usage dependency injection * Review edits
This commit is contained in:
@@ -135,10 +135,14 @@ class PubResultEvent extends UsageEvent {
|
||||
/// An event that reports something about a build.
|
||||
class BuildEvent extends UsageEvent {
|
||||
BuildEvent(String label, {
|
||||
this.command,
|
||||
this.settings,
|
||||
this.eventError,
|
||||
}) : super(
|
||||
String command,
|
||||
String settings,
|
||||
String eventError,
|
||||
@required Usage flutterUsage,
|
||||
}) : _command = command,
|
||||
_settings = settings,
|
||||
_eventError = eventError,
|
||||
super(
|
||||
// category
|
||||
'build',
|
||||
// parameter
|
||||
@@ -146,22 +150,22 @@ class BuildEvent extends UsageEvent {
|
||||
? 'unspecified'
|
||||
: FlutterCommand.current.name,
|
||||
label: label,
|
||||
flutterUsage: globals.flutterUsage,
|
||||
flutterUsage: flutterUsage,
|
||||
);
|
||||
|
||||
final String command;
|
||||
final String settings;
|
||||
final String eventError;
|
||||
final String _command;
|
||||
final String _settings;
|
||||
final String _eventError;
|
||||
|
||||
@override
|
||||
void send() {
|
||||
final Map<String, String> parameters = _useCdKeys(<CustomDimensions, String>{
|
||||
if (command != null)
|
||||
CustomDimensions.buildEventCommand: command,
|
||||
if (settings != null)
|
||||
CustomDimensions.buildEventSettings: settings,
|
||||
if (eventError != null)
|
||||
CustomDimensions.buildEventError: eventError,
|
||||
if (_command != null)
|
||||
CustomDimensions.buildEventCommand: _command,
|
||||
if (_settings != null)
|
||||
CustomDimensions.buildEventSettings: _settings,
|
||||
if (_eventError != null)
|
||||
CustomDimensions.buildEventError: _eventError,
|
||||
});
|
||||
flutterUsage.sendEvent(
|
||||
category,
|
||||
|
||||
@@ -83,6 +83,8 @@ abstract class Usage {
|
||||
analyticsIOFactory: analyticsIOFactory,
|
||||
runningOnBot: runningOnBot);
|
||||
|
||||
factory Usage.test() => _DefaultUsage.test();
|
||||
|
||||
/// Uses the global [Usage] instance to send a 'command' to analytics.
|
||||
static void command(String command, {
|
||||
Map<CustomDimensions, String> parameters,
|
||||
@@ -265,6 +267,10 @@ class _DefaultUsage implements Usage {
|
||||
_analytics.analyticsOpt = AnalyticsOpt.optOut;
|
||||
}
|
||||
|
||||
_DefaultUsage.test() :
|
||||
_suppressAnalytics = true,
|
||||
_analytics = AnalyticsMock();
|
||||
|
||||
Analytics _analytics;
|
||||
|
||||
bool _printedWelcome = false;
|
||||
|
||||
Reference in New Issue
Block a user