[flutter_tools] report basic analytics for null-safety (#71487)

This commit is contained in:
Jonah Williams
2020-12-03 15:14:20 -08:00
committed by GitHub
parent b358854172
commit c92cc25830
10 changed files with 223 additions and 0 deletions

View File

@@ -487,6 +487,9 @@ abstract class FlutterCommand extends Command<void> {
/// Whether it is safe for this command to use a cached pub invocation.
bool get cachePubGet => true;
/// Whether this command should report null safety analytics.
bool get reportNullSafety => false;
Duration get deviceDiscoveryTimeout {
if (_deviceDiscoveryTimeout == null
&& argResults.options.contains(FlutterOptions.kDeviceTimeout)
@@ -1112,6 +1115,9 @@ abstract class FlutterCommand extends Command<void> {
checkUpToDate: cachePubGet,
);
await project.regeneratePlatformSpecificTooling();
if (reportNullSafety) {
await _sendNullSafetyAnalyticsEvents(project);
}
}
setupApplicationPackages();
@@ -1128,6 +1134,16 @@ abstract class FlutterCommand extends Command<void> {
return await runCommand();
}
Future<void> _sendNullSafetyAnalyticsEvents(FlutterProject project) async {
final BuildInfo buildInfo = await getBuildInfo();
NullSafetyAnalysisEvent(
buildInfo.packageConfig,
buildInfo.nullSafetyMode,
project.manifest.appName,
globals.flutterUsage,
).send();
}
/// The set of development artifacts required for this command.
///
/// Defaults to an empty set. Including [DevelopmentArtifact.universal] is