[reland] delete FlutterCommand.usageValues (#162550)

Relands https://github.com/flutter/flutter/pull/162468

The original PR broke g3 postsubmit, because there was an override of
`FlutterCommand.usageValues`. This was since deleted.

## Original PR description
toward https://github.com/flutter/flutter/issues/150575. More simple
deletes.

<details>

<summary> Pre-launch checklist </summary> 


- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

</details>

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
Andrew Kolos
2025-02-03 12:26:04 -08:00
committed by GitHub
parent a612fda649
commit 2f2bda3504
16 changed files with 173 additions and 266 deletions

View File

@@ -24,7 +24,6 @@ import '../cache.dart';
import '../convert.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart';
/// All currently implemented targets.
@@ -163,12 +162,6 @@ class AssembleCommand extends FlutterCommand {
@override
String get category => FlutterCommandCategory.project;
@override
Future<CustomDimensions> get usageValues async => CustomDimensions(
commandBuildBundleTargetPlatform: _environment.defines[kTargetPlatform],
commandBuildBundleIsModule: _flutterProject.isModule,
);
@override
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async => Event.commandUsageValues(
workflow: commandPath,

View File

@@ -14,7 +14,6 @@ import '../build_info.dart';
import '../cache.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
import 'build.dart';
@@ -76,23 +75,6 @@ class BuildAarCommand extends BuildSubCommand {
@override
late final FlutterProject project = _getProject();
@override
Future<CustomDimensions> get usageValues async {
final String projectType;
if (project.manifest.isModule) {
projectType = 'module';
} else if (project.manifest.isPlugin) {
projectType = 'plugin';
} else {
projectType = 'app';
}
return CustomDimensions(
commandBuildAarProjectType: projectType,
commandBuildAarTargetPlatform: stringsArg('target-platform').join(','),
);
}
@override
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async {
final String projectType;

View File

@@ -11,7 +11,6 @@ import '../build_info.dart';
import '../cache.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
import 'build.dart';
@@ -115,15 +114,6 @@ class BuildApkCommand extends BuildSubCommand {
' * https://developer.android.com/guide/app-bundle\n'
' * https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split';
@override
Future<CustomDimensions> get usageValues async {
return CustomDimensions(
commandBuildApkTargetPlatform: _targetArchs.join(','),
commandBuildApkBuildMode: _buildMode.cliName,
commandBuildApkSplitPerAbi: boolArg('split-per-abi'),
);
}
@override
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async {
return Event.commandUsageValues(

View File

@@ -14,7 +14,6 @@ import '../build_info.dart';
import '../cache.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
import 'build.dart';
@@ -92,27 +91,6 @@ class BuildAppBundleCommand extends BuildSubCommand {
"debugging and a quick development cycle. 'release' builds don't support debugging and are "
'suitable for deploying to app stores. \n app bundle improves your app size';
@override
Future<CustomDimensions> get usageValues async {
String buildMode;
if (boolArg('release')) {
buildMode = 'release';
} else if (boolArg('debug')) {
buildMode = 'debug';
} else if (boolArg('profile')) {
buildMode = 'profile';
} else {
// The build defaults to release.
buildMode = 'release';
}
return CustomDimensions(
commandBuildAppBundleTargetPlatform: stringsArg('target-platform').join(','),
commandBuildAppBundleBuildMode: buildMode,
);
}
@override
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async {
final String buildMode;

View File

@@ -11,7 +11,6 @@ import '../bundle_builder.dart';
import '../features.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart';
import 'build.dart';
@@ -83,18 +82,6 @@ class BuildBundleCommand extends BuildSubCommand {
'application code and resources; they are used by some Flutter Android and'
' iOS runtimes.';
@override
Future<CustomDimensions> get usageValues async {
final String projectDir = globals.fs.file(targetFile).parent.parent.path;
final FlutterProject flutterProject = FlutterProject.fromDirectory(
globals.fs.directory(projectDir),
);
return CustomDimensions(
commandBuildBundleTargetPlatform: stringArg('target-platform'),
commandBuildBundleIsModule: flutterProject.isModule,
);
}
@override
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async {
final String projectDir = globals.fs.file(targetFile).parent.parent.path;

View File

@@ -24,7 +24,6 @@ import '../ios/code_signing.dart';
import '../macos/swift_package_manager.dart';
import '../macos/swift_packages.dart';
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart';
import 'create_base.dart';
@@ -155,15 +154,6 @@ class CreateCommand extends FlutterCommand with CreateBase {
@override
String get invocation => '${runner?.executableName} $name <output directory>';
@override
Future<CustomDimensions> get usageValues async {
return CustomDimensions(
commandCreateProjectType: stringArg('template'),
commandCreateAndroidLanguage: stringArg('android-language'),
commandCreateIosLanguage: stringArg('ios-language'),
);
}
@override
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async => Event.commandUsageValues(
workflow: commandPath,

View File

@@ -19,7 +19,6 @@ import '../flutter_plugins.dart';
import '../globals.dart' as globals;
import '../plugins.dart';
import '../project.dart';
import '../reporting/reporting.dart';
import '../runner/flutter_command.dart';
class PackagesCommand extends FlutterCommand {
@@ -397,36 +396,6 @@ class PackagesGetCommand extends FlutterCommand {
late final String? _androidEmbeddingVersion =
_rootProject?.android.getEmbeddingVersion().toString().split('.').last;
/// The pub packages usage values are incorrect since these are calculated/sent
/// before pub get completes. This needs to be performed after dependency resolution.
@override
Future<CustomDimensions> get usageValues async {
final FlutterProject? rootProject = _rootProject;
if (rootProject == null) {
return const CustomDimensions();
}
int numberPlugins;
// Do not send plugin analytics if pub has not run before.
final bool hasPlugins =
rootProject.flutterPluginsDependenciesFile.existsSync() &&
findPackageConfigFile(rootProject.directory) != null;
if (hasPlugins) {
// Do not fail pub get if package config files are invalid before pub has
// had a chance to run.
final List<Plugin> plugins = await _pluginsFound;
numberPlugins = plugins.length;
} else {
numberPlugins = 0;
}
return CustomDimensions(
commandPackagesNumberPlugins: numberPlugins,
commandPackagesProjectModule: rootProject.isModule,
commandPackagesAndroidEmbeddingVersion: _androidEmbeddingVersion,
);
}
/// The pub packages usage values are incorrect since these are calculated/sent
/// before pub get completes. This needs to be performed after dependency resolution.
@override

View File

@@ -20,7 +20,6 @@ import '../features.dart';
import '../globals.dart' as globals;
import '../ios/devices.dart';
import '../project.dart';
import '../reporting/reporting.dart';
import '../resident_runner.dart';
import '../run_cold.dart';
import '../run_hot.dart';
@@ -532,24 +531,6 @@ class RunCommand extends RunCommandBase {
return '$command/${getNameForTargetPlatform(await devices![0].targetPlatform)}';
}
@override
Future<CustomDimensions> get usageValues async {
final AnalyticsUsageValuesRecord record = await _sharedAnalyticsUsageValues;
return CustomDimensions(
commandRunIsEmulator: record.runIsEmulator,
commandRunTargetName: record.runTargetName,
commandRunTargetOsVersion: record.runTargetOsVersion,
commandRunModeName: record.runModeName,
commandRunProjectModule: record.runProjectModule,
commandRunProjectHostLanguage: record.runProjectHostLanguage,
commandRunAndroidEmbeddingVersion: record.runAndroidEmbeddingVersion,
commandRunEnableImpeller: record.runEnableImpeller,
commandRunIOSInterfaceType: record.runIOSInterfaceType,
commandRunIsTest: record.runIsTest,
);
}
@override
Future<analytics.Event> unifiedAnalyticsUsageValues(String commandPath) async {
final AnalyticsUsageValuesRecord record = await _sharedAnalyticsUsageValues;

View File

@@ -1518,9 +1518,6 @@ abstract class FlutterCommand extends Command<void> {
}
}
/// Additional usage values to be sent with the usage ping.
Future<CustomDimensions> get usageValues async => const CustomDimensions();
/// Additional usage values to be sent with the usage ping for
/// package:unified_analytics.
///
@@ -1915,20 +1912,7 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
setupApplicationPackages();
if (commandPath != null) {
// Until the GA4 migration is complete, we will continue to send to the GA3 instance
// as well as GA4. Once migration is complete, we will only make a call for GA4 values
final List<Object> pairOfUsageValues = await Future.wait<Object>(<Future<Object>>[
usageValues,
unifiedAnalyticsUsageValues(commandPath),
]);
Usage.command(
commandPath,
parameters: CustomDimensions(
commandHasTerminal: hasTerminal,
).merge(pairOfUsageValues[0] as CustomDimensions),
);
analytics.send(pairOfUsageValues[1] as Event);
analytics.send(await unifiedAnalyticsUsageValues(commandPath));
}
return runCommand();