Skip to content

Commit 0d7f371

Browse files
authored
Delete FlutterCommand.usageValues (#162468)
toward flutter/flutter#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
1 parent d0d4e96 commit 0d7f371

File tree

15 files changed

+172
-252
lines changed

15 files changed

+172
-252
lines changed

packages/flutter_tools/lib/src/commands/assemble.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import '../cache.dart';
2424
import '../convert.dart';
2525
import '../globals.dart' as globals;
2626
import '../project.dart';
27-
import '../reporting/reporting.dart';
2827
import '../runner/flutter_command.dart';
2928

3029
/// All currently implemented targets.
@@ -163,12 +162,6 @@ class AssembleCommand extends FlutterCommand {
163162
@override
164163
String get category => FlutterCommandCategory.project;
165164

166-
@override
167-
Future<CustomDimensions> get usageValues async => CustomDimensions(
168-
commandBuildBundleTargetPlatform: _environment.defines[kTargetPlatform],
169-
commandBuildBundleIsModule: _flutterProject.isModule,
170-
);
171-
172165
@override
173166
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async => Event.commandUsageValues(
174167
workflow: commandPath,

packages/flutter_tools/lib/src/commands/build_aar.dart

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import '../build_info.dart';
1414
import '../cache.dart';
1515
import '../globals.dart' as globals;
1616
import '../project.dart';
17-
import '../reporting/reporting.dart';
1817
import '../runner/flutter_command.dart' show FlutterCommandResult;
1918
import 'build.dart';
2019

@@ -76,23 +75,6 @@ class BuildAarCommand extends BuildSubCommand {
7675
@override
7776
late final FlutterProject project = _getProject();
7877

79-
@override
80-
Future<CustomDimensions> get usageValues async {
81-
final String projectType;
82-
if (project.manifest.isModule) {
83-
projectType = 'module';
84-
} else if (project.manifest.isPlugin) {
85-
projectType = 'plugin';
86-
} else {
87-
projectType = 'app';
88-
}
89-
90-
return CustomDimensions(
91-
commandBuildAarProjectType: projectType,
92-
commandBuildAarTargetPlatform: stringsArg('target-platform').join(','),
93-
);
94-
}
95-
9678
@override
9779
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async {
9880
final String projectType;

packages/flutter_tools/lib/src/commands/build_apk.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import '../build_info.dart';
1111
import '../cache.dart';
1212
import '../globals.dart' as globals;
1313
import '../project.dart';
14-
import '../reporting/reporting.dart';
1514
import '../runner/flutter_command.dart' show FlutterCommandResult;
1615
import 'build.dart';
1716

@@ -115,15 +114,6 @@ class BuildApkCommand extends BuildSubCommand {
115114
' * https://developer.android.com/guide/app-bundle\n'
116115
' * https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split';
117116

118-
@override
119-
Future<CustomDimensions> get usageValues async {
120-
return CustomDimensions(
121-
commandBuildApkTargetPlatform: _targetArchs.join(','),
122-
commandBuildApkBuildMode: _buildMode.cliName,
123-
commandBuildApkSplitPerAbi: boolArg('split-per-abi'),
124-
);
125-
}
126-
127117
@override
128118
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async {
129119
return Event.commandUsageValues(

packages/flutter_tools/lib/src/commands/build_appbundle.dart

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import '../build_info.dart';
1414
import '../cache.dart';
1515
import '../globals.dart' as globals;
1616
import '../project.dart';
17-
import '../reporting/reporting.dart';
1817
import '../runner/flutter_command.dart' show FlutterCommandResult;
1918
import 'build.dart';
2019

@@ -92,27 +91,6 @@ class BuildAppBundleCommand extends BuildSubCommand {
9291
"debugging and a quick development cycle. 'release' builds don't support debugging and are "
9392
'suitable for deploying to app stores. \n app bundle improves your app size';
9493

95-
@override
96-
Future<CustomDimensions> get usageValues async {
97-
String buildMode;
98-
99-
if (boolArg('release')) {
100-
buildMode = 'release';
101-
} else if (boolArg('debug')) {
102-
buildMode = 'debug';
103-
} else if (boolArg('profile')) {
104-
buildMode = 'profile';
105-
} else {
106-
// The build defaults to release.
107-
buildMode = 'release';
108-
}
109-
110-
return CustomDimensions(
111-
commandBuildAppBundleTargetPlatform: stringsArg('target-platform').join(','),
112-
commandBuildAppBundleBuildMode: buildMode,
113-
);
114-
}
115-
11694
@override
11795
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async {
11896
final String buildMode;

packages/flutter_tools/lib/src/commands/build_bundle.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import '../bundle_builder.dart';
1111
import '../features.dart';
1212
import '../globals.dart' as globals;
1313
import '../project.dart';
14-
import '../reporting/reporting.dart';
1514
import '../runner/flutter_command.dart';
1615
import 'build.dart';
1716

@@ -83,18 +82,6 @@ class BuildBundleCommand extends BuildSubCommand {
8382
'application code and resources; they are used by some Flutter Android and'
8483
' iOS runtimes.';
8584

86-
@override
87-
Future<CustomDimensions> get usageValues async {
88-
final String projectDir = globals.fs.file(targetFile).parent.parent.path;
89-
final FlutterProject flutterProject = FlutterProject.fromDirectory(
90-
globals.fs.directory(projectDir),
91-
);
92-
return CustomDimensions(
93-
commandBuildBundleTargetPlatform: stringArg('target-platform'),
94-
commandBuildBundleIsModule: flutterProject.isModule,
95-
);
96-
}
97-
9885
@override
9986
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async {
10087
final String projectDir = globals.fs.file(targetFile).parent.parent.path;

packages/flutter_tools/lib/src/commands/create.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import '../ios/code_signing.dart';
2424
import '../macos/swift_package_manager.dart';
2525
import '../macos/swift_packages.dart';
2626
import '../project.dart';
27-
import '../reporting/reporting.dart';
2827
import '../runner/flutter_command.dart';
2928
import 'create_base.dart';
3029

@@ -155,15 +154,6 @@ class CreateCommand extends FlutterCommand with CreateBase {
155154
@override
156155
String get invocation => '${runner?.executableName} $name <output directory>';
157156

158-
@override
159-
Future<CustomDimensions> get usageValues async {
160-
return CustomDimensions(
161-
commandCreateProjectType: stringArg('template'),
162-
commandCreateAndroidLanguage: stringArg('android-language'),
163-
commandCreateIosLanguage: stringArg('ios-language'),
164-
);
165-
}
166-
167157
@override
168158
Future<Event> unifiedAnalyticsUsageValues(String commandPath) async => Event.commandUsageValues(
169159
workflow: commandPath,

packages/flutter_tools/lib/src/commands/packages.dart

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import '../flutter_plugins.dart';
1919
import '../globals.dart' as globals;
2020
import '../plugins.dart';
2121
import '../project.dart';
22-
import '../reporting/reporting.dart';
2322
import '../runner/flutter_command.dart';
2423

2524
class PackagesCommand extends FlutterCommand {
@@ -397,36 +396,6 @@ class PackagesGetCommand extends FlutterCommand {
397396
late final String? _androidEmbeddingVersion =
398397
_rootProject?.android.getEmbeddingVersion().toString().split('.').last;
399398

400-
/// The pub packages usage values are incorrect since these are calculated/sent
401-
/// before pub get completes. This needs to be performed after dependency resolution.
402-
@override
403-
Future<CustomDimensions> get usageValues async {
404-
final FlutterProject? rootProject = _rootProject;
405-
if (rootProject == null) {
406-
return const CustomDimensions();
407-
}
408-
409-
int numberPlugins;
410-
// Do not send plugin analytics if pub has not run before.
411-
final bool hasPlugins =
412-
rootProject.flutterPluginsDependenciesFile.existsSync() &&
413-
findPackageConfigFile(rootProject.directory) != null;
414-
if (hasPlugins) {
415-
// Do not fail pub get if package config files are invalid before pub has
416-
// had a chance to run.
417-
final List<Plugin> plugins = await _pluginsFound;
418-
numberPlugins = plugins.length;
419-
} else {
420-
numberPlugins = 0;
421-
}
422-
423-
return CustomDimensions(
424-
commandPackagesNumberPlugins: numberPlugins,
425-
commandPackagesProjectModule: rootProject.isModule,
426-
commandPackagesAndroidEmbeddingVersion: _androidEmbeddingVersion,
427-
);
428-
}
429-
430399
/// The pub packages usage values are incorrect since these are calculated/sent
431400
/// before pub get completes. This needs to be performed after dependency resolution.
432401
@override

packages/flutter_tools/lib/src/commands/run.dart

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import '../features.dart';
2020
import '../globals.dart' as globals;
2121
import '../ios/devices.dart';
2222
import '../project.dart';
23-
import '../reporting/reporting.dart';
2423
import '../resident_runner.dart';
2524
import '../run_cold.dart';
2625
import '../run_hot.dart';
@@ -532,24 +531,6 @@ class RunCommand extends RunCommandBase {
532531
return '$command/${getNameForTargetPlatform(await devices![0].targetPlatform)}';
533532
}
534533

535-
@override
536-
Future<CustomDimensions> get usageValues async {
537-
final AnalyticsUsageValuesRecord record = await _sharedAnalyticsUsageValues;
538-
539-
return CustomDimensions(
540-
commandRunIsEmulator: record.runIsEmulator,
541-
commandRunTargetName: record.runTargetName,
542-
commandRunTargetOsVersion: record.runTargetOsVersion,
543-
commandRunModeName: record.runModeName,
544-
commandRunProjectModule: record.runProjectModule,
545-
commandRunProjectHostLanguage: record.runProjectHostLanguage,
546-
commandRunAndroidEmbeddingVersion: record.runAndroidEmbeddingVersion,
547-
commandRunEnableImpeller: record.runEnableImpeller,
548-
commandRunIOSInterfaceType: record.runIOSInterfaceType,
549-
commandRunIsTest: record.runIsTest,
550-
);
551-
}
552-
553534
@override
554535
Future<analytics.Event> unifiedAnalyticsUsageValues(String commandPath) async {
555536
final AnalyticsUsageValuesRecord record = await _sharedAnalyticsUsageValues;

packages/flutter_tools/lib/src/runner/flutter_command.dart

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,9 +1518,6 @@ abstract class FlutterCommand extends Command<void> {
15181518
}
15191519
}
15201520

1521-
/// Additional usage values to be sent with the usage ping.
1522-
Future<CustomDimensions> get usageValues async => const CustomDimensions();
1523-
15241521
/// Additional usage values to be sent with the usage ping for
15251522
/// package:unified_analytics.
15261523
///
@@ -1915,20 +1912,7 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
19151912
setupApplicationPackages();
19161913

19171914
if (commandPath != null) {
1918-
// Until the GA4 migration is complete, we will continue to send to the GA3 instance
1919-
// as well as GA4. Once migration is complete, we will only make a call for GA4 values
1920-
final List<Object> pairOfUsageValues = await Future.wait<Object>(<Future<Object>>[
1921-
usageValues,
1922-
unifiedAnalyticsUsageValues(commandPath),
1923-
]);
1924-
1925-
Usage.command(
1926-
commandPath,
1927-
parameters: CustomDimensions(
1928-
commandHasTerminal: hasTerminal,
1929-
).merge(pairOfUsageValues[0] as CustomDimensions),
1930-
);
1931-
analytics.send(pairOfUsageValues[1] as Event);
1915+
analytics.send(await unifiedAnalyticsUsageValues(commandPath));
19321916
}
19331917

19341918
return runCommand();

packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,35 @@ void main() {
188188
final CommandRunner<void> runner = createTestCommandRunner(command);
189189

190190
await runner.run(<String>['create', '--no-pub', '--template=module', 'testy']);
191-
expect((await command.usageValues).commandCreateProjectType, 'module');
192-
191+
expect(
192+
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
193+
'module',
194+
);
193195
await runner.run(<String>['create', '--no-pub', '--template=app', 'testy1']);
194-
expect((await command.usageValues).commandCreateProjectType, 'app');
195-
196+
expect(
197+
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
198+
'app',
199+
);
196200
await runner.run(<String>['create', '--no-pub', '--template=package', 'testy3']);
197-
expect((await command.usageValues).commandCreateProjectType, 'package');
198-
201+
expect(
202+
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
203+
'package',
204+
);
199205
await runner.run(<String>['create', '--no-pub', '--template=plugin', 'testy4']);
200-
expect((await command.usageValues).commandCreateProjectType, 'plugin');
201-
206+
expect(
207+
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
208+
'plugin',
209+
);
202210
await runner.run(<String>['create', '--no-pub', '--template=plugin_ffi', 'testy5']);
203-
expect((await command.usageValues).commandCreateProjectType, 'plugin_ffi');
204-
211+
expect(
212+
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
213+
'plugin_ffi',
214+
);
205215
await runner.run(<String>['create', '--no-pub', '--template=package_ffi', 'testy6']);
206-
expect((await command.usageValues).commandCreateProjectType, 'package_ffi');
216+
expect(
217+
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
218+
'package_ffi',
219+
);
207220
}),
208221
overrides: <Type, Generator>{Java: () => FakeJava()},
209222
);
@@ -215,7 +228,10 @@ void main() {
215228
final CommandRunner<void> runner = createTestCommandRunner(command);
216229

217230
await runner.run(<String>['create', '--no-pub', '--template=app', 'testy']);
218-
expect((await command.usageValues).commandCreateIosLanguage, 'swift');
231+
expect(
232+
(await command.unifiedAnalyticsUsageValues('create')).eventData['createIosLanguage'],
233+
'swift',
234+
);
219235

220236
await runner.run(<String>[
221237
'create',
@@ -224,7 +240,10 @@ void main() {
224240
'--ios-language=objc',
225241
'testy',
226242
]);
227-
expect((await command.usageValues).commandCreateIosLanguage, 'objc');
243+
expect(
244+
(await command.unifiedAnalyticsUsageValues('create')).eventData['createIosLanguage'],
245+
'objc',
246+
);
228247
}),
229248
overrides: <Type, Generator>{Java: () => FakeJava()},
230249
);
@@ -236,7 +255,10 @@ void main() {
236255
final CommandRunner<void> runner = createTestCommandRunner(command);
237256

238257
await runner.run(<String>['create', '--no-pub', '--template=app', 'testy']);
239-
expect((await command.usageValues).commandCreateAndroidLanguage, 'kotlin');
258+
expect(
259+
(await command.unifiedAnalyticsUsageValues('create')).eventData['createAndroidLanguage'],
260+
'kotlin',
261+
);
240262

241263
await runner.run(<String>[
242264
'create',
@@ -245,7 +267,10 @@ void main() {
245267
'--android-language=java',
246268
'testy',
247269
]);
248-
expect((await command.usageValues).commandCreateAndroidLanguage, 'java');
270+
expect(
271+
(await command.unifiedAnalyticsUsageValues('create')).eventData['createAndroidLanguage'],
272+
'java',
273+
);
249274
}),
250275
overrides: <Type, Generator>{Java: () => FakeJava()},
251276
);

0 commit comments

Comments
 (0)