[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:
parent
a612fda649
commit
2f2bda3504
@ -627,7 +627,6 @@ end
|
||||
swiftHostApp,
|
||||
);
|
||||
|
||||
final File swiftAnalyticsOutputFile = File(path.join(tempDir.path, 'analytics-swift.log'));
|
||||
final Directory swiftBuildDirectory = Directory(path.join(tempDir.path, 'build-swift'));
|
||||
|
||||
await inDirectory(swiftHostApp, () async {
|
||||
@ -652,9 +651,7 @@ end
|
||||
'BUILD_DIR=${swiftBuildDirectory.path}',
|
||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||
],
|
||||
environment: <String, String>{
|
||||
'FLUTTER_ANALYTICS_LOG_FILE': swiftAnalyticsOutputFile.path,
|
||||
},
|
||||
environment: <String, String>{'FLUTTER_SUPPRESS_ANALYTICS': 'true'},
|
||||
);
|
||||
});
|
||||
|
||||
@ -665,16 +662,6 @@ end
|
||||
return TaskResult.failure('Failed to build existing Swift app .app');
|
||||
}
|
||||
|
||||
final String swiftAnalyticsOutput = swiftAnalyticsOutputFile.readAsStringSync();
|
||||
if (!swiftAnalyticsOutput.contains('cd24: ios') ||
|
||||
!swiftAnalyticsOutput.contains('cd25: true') ||
|
||||
!swiftAnalyticsOutput.contains('viewName: assemble')) {
|
||||
return TaskResult.failure(
|
||||
'Building outer Swift app produced the following analytics: "$swiftAnalyticsOutput" '
|
||||
'but not the expected strings: "cd24: ios", "cd25: true", "viewName: assemble"',
|
||||
);
|
||||
}
|
||||
|
||||
return TaskResult.success(null);
|
||||
} catch (e) {
|
||||
return TaskResult.failure(e.toString());
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -188,22 +188,35 @@ void main() {
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
|
||||
await runner.run(<String>['create', '--no-pub', '--template=module', 'testy']);
|
||||
expect((await command.usageValues).commandCreateProjectType, 'module');
|
||||
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
|
||||
'module',
|
||||
);
|
||||
await runner.run(<String>['create', '--no-pub', '--template=app', 'testy1']);
|
||||
expect((await command.usageValues).commandCreateProjectType, 'app');
|
||||
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
|
||||
'app',
|
||||
);
|
||||
await runner.run(<String>['create', '--no-pub', '--template=package', 'testy3']);
|
||||
expect((await command.usageValues).commandCreateProjectType, 'package');
|
||||
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
|
||||
'package',
|
||||
);
|
||||
await runner.run(<String>['create', '--no-pub', '--template=plugin', 'testy4']);
|
||||
expect((await command.usageValues).commandCreateProjectType, 'plugin');
|
||||
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
|
||||
'plugin',
|
||||
);
|
||||
await runner.run(<String>['create', '--no-pub', '--template=plugin_ffi', 'testy5']);
|
||||
expect((await command.usageValues).commandCreateProjectType, 'plugin_ffi');
|
||||
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
|
||||
'plugin_ffi',
|
||||
);
|
||||
await runner.run(<String>['create', '--no-pub', '--template=package_ffi', 'testy6']);
|
||||
expect((await command.usageValues).commandCreateProjectType, 'package_ffi');
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('create')).eventData['createProjectType'],
|
||||
'package_ffi',
|
||||
);
|
||||
}),
|
||||
overrides: <Type, Generator>{Java: () => FakeJava()},
|
||||
);
|
||||
@ -215,7 +228,10 @@ void main() {
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
|
||||
await runner.run(<String>['create', '--no-pub', '--template=app', 'testy']);
|
||||
expect((await command.usageValues).commandCreateIosLanguage, 'swift');
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('create')).eventData['createIosLanguage'],
|
||||
'swift',
|
||||
);
|
||||
|
||||
await runner.run(<String>[
|
||||
'create',
|
||||
@ -224,7 +240,10 @@ void main() {
|
||||
'--ios-language=objc',
|
||||
'testy',
|
||||
]);
|
||||
expect((await command.usageValues).commandCreateIosLanguage, 'objc');
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('create')).eventData['createIosLanguage'],
|
||||
'objc',
|
||||
);
|
||||
}),
|
||||
overrides: <Type, Generator>{Java: () => FakeJava()},
|
||||
);
|
||||
@ -236,7 +255,10 @@ void main() {
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
|
||||
await runner.run(<String>['create', '--no-pub', '--template=app', 'testy']);
|
||||
expect((await command.usageValues).commandCreateAndroidLanguage, 'kotlin');
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('create')).eventData['createAndroidLanguage'],
|
||||
'kotlin',
|
||||
);
|
||||
|
||||
await runner.run(<String>[
|
||||
'create',
|
||||
@ -245,7 +267,10 @@ void main() {
|
||||
'--android-language=java',
|
||||
'testy',
|
||||
]);
|
||||
expect((await command.usageValues).commandCreateAndroidLanguage, 'java');
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('create')).eventData['createAndroidLanguage'],
|
||||
'java',
|
||||
);
|
||||
}),
|
||||
overrides: <Type, Generator>{Java: () => FakeJava()},
|
||||
);
|
||||
|
@ -11,9 +11,9 @@ import 'package:flutter_tools/src/commands/packages.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||
import 'package:test/fake.dart';
|
||||
import 'package:unified_analytics/unified_analytics.dart';
|
||||
|
||||
import '../../src/context.dart';
|
||||
import '../../src/fake_pub_deps.dart';
|
||||
@ -86,11 +86,13 @@ void main() {
|
||||
await commandRunner.run(<String>['get']);
|
||||
|
||||
expect(
|
||||
await command.usageValues,
|
||||
const CustomDimensions(
|
||||
commandPackagesNumberPlugins: 0,
|
||||
commandPackagesProjectModule: false,
|
||||
commandPackagesAndroidEmbeddingVersion: 'v2',
|
||||
await command.unifiedAnalyticsUsageValues('pub'),
|
||||
Event.commandUsageValues(
|
||||
workflow: 'pub',
|
||||
commandHasTerminal: false,
|
||||
packagesNumberPlugins: 0,
|
||||
packagesProjectModule: false,
|
||||
packagesAndroidEmbeddingVersion: 'v2',
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -120,11 +122,13 @@ void main() {
|
||||
await commandRunner.run(<String>['get']);
|
||||
|
||||
expect(
|
||||
await command.usageValues,
|
||||
const CustomDimensions(
|
||||
commandPackagesNumberPlugins: 0,
|
||||
commandPackagesProjectModule: false,
|
||||
commandPackagesAndroidEmbeddingVersion: 'v2',
|
||||
await command.unifiedAnalyticsUsageValues('pub'),
|
||||
Event.commandUsageValues(
|
||||
workflow: 'pub',
|
||||
commandHasTerminal: false,
|
||||
packagesNumberPlugins: 0,
|
||||
packagesProjectModule: false,
|
||||
packagesAndroidEmbeddingVersion: 'v2',
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -239,11 +243,13 @@ void main() {
|
||||
await commandRunner.run(<String>['get']);
|
||||
|
||||
expect(
|
||||
await command.usageValues,
|
||||
const CustomDimensions(
|
||||
commandPackagesNumberPlugins: 0,
|
||||
commandPackagesProjectModule: false,
|
||||
commandPackagesAndroidEmbeddingVersion: 'v2',
|
||||
await command.unifiedAnalyticsUsageValues('pub'),
|
||||
Event.commandUsageValues(
|
||||
workflow: 'pub',
|
||||
commandHasTerminal: false,
|
||||
packagesNumberPlugins: 0,
|
||||
packagesProjectModule: false,
|
||||
packagesAndroidEmbeddingVersion: 'v2',
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -24,7 +24,6 @@ import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/ios/devices.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/resident_runner.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||
import 'package:flutter_tools/src/web/compile.dart';
|
||||
@ -220,7 +219,6 @@ void main() {
|
||||
group('run app', () {
|
||||
late MemoryFileSystem fs;
|
||||
late Artifacts artifacts;
|
||||
late TestUsage usage;
|
||||
late FakeAnsiTerminal fakeTerminal;
|
||||
late analytics.FakeAnalytics fakeAnalytics;
|
||||
|
||||
@ -231,7 +229,6 @@ void main() {
|
||||
setUp(() {
|
||||
fakeTerminal = FakeAnsiTerminal();
|
||||
artifacts = Artifacts.test();
|
||||
usage = TestUsage();
|
||||
fs = MemoryFileSystem.test();
|
||||
|
||||
fs.currentDirectory.childFile('pubspec.yaml').writeAsStringSync('name: flutter_app');
|
||||
@ -474,7 +471,6 @@ void main() {
|
||||
DeviceManager: () => testDeviceManager,
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Usage: () => usage,
|
||||
},
|
||||
);
|
||||
|
||||
@ -524,7 +520,6 @@ void main() {
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Stdio: () => FakeStdio(),
|
||||
Usage: () => usage,
|
||||
analytics.Analytics: () => fakeAnalytics,
|
||||
},
|
||||
);
|
||||
@ -579,7 +574,6 @@ void main() {
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Stdio: () => FakeStdio(),
|
||||
Usage: () => usage,
|
||||
analytics.Analytics: () => fakeAnalytics,
|
||||
},
|
||||
);
|
||||
@ -612,7 +606,6 @@ void main() {
|
||||
DeviceManager: () => testDeviceManager,
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Usage: () => usage,
|
||||
Stdio: () => FakeStdio(),
|
||||
Logger: () => AppRunLogger(parent: logger),
|
||||
},
|
||||
@ -639,7 +632,6 @@ void main() {
|
||||
DeviceManager: () => testDeviceManager,
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Usage: () => usage,
|
||||
Stdio: () => FakeStdio(),
|
||||
Logger: () => AppRunLogger(parent: logger),
|
||||
},
|
||||
@ -819,18 +811,22 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
final CustomDimensions dimensions = await command.usageValues;
|
||||
final analytics.Event usageValues = await command.unifiedAnalyticsUsageValues('run');
|
||||
|
||||
expect(
|
||||
dimensions,
|
||||
const CustomDimensions(
|
||||
commandRunIsEmulator: false,
|
||||
commandRunTargetName: 'android-arm',
|
||||
commandRunTargetOsVersion: '',
|
||||
commandRunModeName: 'debug',
|
||||
commandRunProjectModule: false,
|
||||
commandRunProjectHostLanguage: '',
|
||||
commandRunIsTest: false,
|
||||
usageValues,
|
||||
equals(
|
||||
analytics.Event.commandUsageValues(
|
||||
workflow: 'run',
|
||||
commandHasTerminal: false,
|
||||
runIsEmulator: false,
|
||||
runTargetName: 'android-arm',
|
||||
runTargetOsVersion: '',
|
||||
runModeName: 'debug',
|
||||
runProjectModule: false,
|
||||
runProjectHostLanguage: '',
|
||||
runIsTest: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -866,19 +862,23 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
final CustomDimensions dimensions = await command.usageValues;
|
||||
final analytics.Event usageValues = await command.unifiedAnalyticsUsageValues('run');
|
||||
|
||||
expect(
|
||||
dimensions,
|
||||
const CustomDimensions(
|
||||
commandRunIsEmulator: false,
|
||||
commandRunTargetName: 'ios',
|
||||
commandRunTargetOsVersion: 'iOS 16.2',
|
||||
commandRunModeName: 'debug',
|
||||
commandRunProjectModule: false,
|
||||
commandRunProjectHostLanguage: '',
|
||||
commandRunIOSInterfaceType: 'usb',
|
||||
commandRunIsTest: false,
|
||||
usageValues,
|
||||
equals(
|
||||
analytics.Event.commandUsageValues(
|
||||
workflow: 'run',
|
||||
commandHasTerminal: false,
|
||||
runIsEmulator: false,
|
||||
runTargetName: 'ios',
|
||||
runTargetOsVersion: 'iOS 16.2',
|
||||
runModeName: 'debug',
|
||||
runProjectModule: false,
|
||||
runProjectHostLanguage: '',
|
||||
runIOSInterfaceType: 'usb',
|
||||
runIsTest: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -919,19 +919,23 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
final CustomDimensions dimensions = await command.usageValues;
|
||||
final analytics.Event usageValues = await command.unifiedAnalyticsUsageValues('run');
|
||||
|
||||
expect(
|
||||
dimensions,
|
||||
const CustomDimensions(
|
||||
commandRunIsEmulator: false,
|
||||
commandRunTargetName: 'ios',
|
||||
commandRunTargetOsVersion: 'iOS 16.2',
|
||||
commandRunModeName: 'debug',
|
||||
commandRunProjectModule: false,
|
||||
commandRunProjectHostLanguage: '',
|
||||
commandRunIOSInterfaceType: 'wireless',
|
||||
commandRunIsTest: false,
|
||||
usageValues,
|
||||
equals(
|
||||
analytics.Event.commandUsageValues(
|
||||
workflow: 'run',
|
||||
commandHasTerminal: false,
|
||||
runIsEmulator: false,
|
||||
runTargetName: 'ios',
|
||||
runTargetOsVersion: 'iOS 16.2',
|
||||
runModeName: 'debug',
|
||||
runProjectModule: false,
|
||||
runProjectHostLanguage: '',
|
||||
runIOSInterfaceType: 'wireless',
|
||||
runIsTest: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -972,19 +976,24 @@ void main() {
|
||||
),
|
||||
);
|
||||
}
|
||||
final CustomDimensions dimensions = await command.usageValues;
|
||||
|
||||
final analytics.Event usageValues = await command.unifiedAnalyticsUsageValues('run');
|
||||
|
||||
expect(
|
||||
dimensions,
|
||||
const CustomDimensions(
|
||||
commandRunIsEmulator: false,
|
||||
commandRunTargetName: 'multiple',
|
||||
commandRunTargetOsVersion: 'multiple',
|
||||
commandRunModeName: 'debug',
|
||||
commandRunProjectModule: false,
|
||||
commandRunProjectHostLanguage: '',
|
||||
commandRunIOSInterfaceType: 'wireless',
|
||||
commandRunIsTest: false,
|
||||
usageValues,
|
||||
equals(
|
||||
analytics.Event.commandUsageValues(
|
||||
workflow: 'run',
|
||||
commandHasTerminal: false,
|
||||
runIsEmulator: false,
|
||||
runTargetName: 'multiple',
|
||||
runTargetOsVersion: 'multiple',
|
||||
runModeName: 'debug',
|
||||
runProjectModule: false,
|
||||
runProjectHostLanguage: '',
|
||||
runIOSInterfaceType: 'wireless',
|
||||
runIsTest: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -16,8 +16,8 @@ import 'package:flutter_tools/src/commands/build_aar.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:test/fake.dart';
|
||||
import 'package:unified_analytics/testing.dart';
|
||||
import 'package:unified_analytics/unified_analytics.dart';
|
||||
|
||||
import '../../src/android_common.dart';
|
||||
@ -44,10 +44,13 @@ void main() {
|
||||
|
||||
group('Usage', () {
|
||||
late Directory tempDir;
|
||||
late TestUsage testUsage;
|
||||
late FakeAnalytics analytics;
|
||||
|
||||
setUp(() {
|
||||
testUsage = TestUsage();
|
||||
analytics = getInitializedFakeAnalyticsInstance(
|
||||
fs: MemoryFileSystem.test(),
|
||||
fakeFlutterVersion: FakeFlutterVersion(),
|
||||
);
|
||||
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
|
||||
});
|
||||
|
||||
@ -63,10 +66,23 @@ void main() {
|
||||
arguments: <String>['--no-pub', '--template=module'],
|
||||
);
|
||||
|
||||
final BuildAarCommand command = await runCommandIn(projectPath);
|
||||
expect((await command.usageValues).commandBuildAarProjectType, 'module');
|
||||
await runCommandIn(projectPath);
|
||||
expect(
|
||||
analytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'aar',
|
||||
buildAarProjectType: 'module',
|
||||
buildAarTargetPlatform: 'android-arm,android-arm64,android-x64',
|
||||
commandHasTerminal: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
AndroidBuilder: () => FakeAndroidBuilder(),
|
||||
Analytics: () => analytics,
|
||||
},
|
||||
overrides: <Type, Generator>{AndroidBuilder: () => FakeAndroidBuilder()},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
@ -77,13 +93,23 @@ void main() {
|
||||
arguments: <String>['--no-pub', '--template=module'],
|
||||
);
|
||||
|
||||
final BuildAarCommand command = await runCommandIn(
|
||||
projectPath,
|
||||
arguments: <String>['--target-platform=android-arm'],
|
||||
await runCommandIn(projectPath, arguments: <String>['--target-platform=android-arm']);
|
||||
expect(
|
||||
analytics.sentEvents,
|
||||
contains(
|
||||
Event.commandUsageValues(
|
||||
workflow: 'aar',
|
||||
buildAarProjectType: 'module',
|
||||
buildAarTargetPlatform: 'android-arm',
|
||||
commandHasTerminal: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
expect((await command.usageValues).commandBuildAarTargetPlatform, 'android-arm');
|
||||
},
|
||||
overrides: <Type, Generator>{AndroidBuilder: () => FakeAndroidBuilder()},
|
||||
overrides: <Type, Generator>{
|
||||
AndroidBuilder: () => FakeAndroidBuilder(),
|
||||
Analytics: () => analytics,
|
||||
},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
@ -96,14 +122,17 @@ void main() {
|
||||
|
||||
await runCommandIn(projectPath, arguments: <String>['--target-platform=android-arm']);
|
||||
|
||||
expect(
|
||||
testUsage.events,
|
||||
contains(const TestUsageEvent('tool-command-result', 'aar', label: 'success')),
|
||||
final Iterable<Event> successEvent = analytics.sentEvents.where(
|
||||
(Event e) =>
|
||||
e.eventName == DashEvent.flutterCommandResult &&
|
||||
e.eventData['commandPath'] == 'create' &&
|
||||
e.eventData['result'] == 'success',
|
||||
);
|
||||
expect(successEvent, isNotEmpty, reason: 'Tool should send create success event');
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
AndroidBuilder: () => FakeAndroidBuilder(),
|
||||
Usage: () => testUsage,
|
||||
Analytics: () => analytics,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
@ -99,9 +99,8 @@ void main() {
|
||||
arguments: <String>['--no-pub', '--template=app'],
|
||||
);
|
||||
|
||||
final BuildBundleCommand command = await runCommandIn(projectPath);
|
||||
await runCommandIn(projectPath);
|
||||
|
||||
expect((await command.usageValues).commandBuildBundleIsModule, false);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
@ -125,7 +124,10 @@ void main() {
|
||||
|
||||
final BuildBundleCommand command = await runCommandIn(projectPath);
|
||||
|
||||
expect((await command.usageValues).commandBuildBundleTargetPlatform, 'android-arm');
|
||||
expect(
|
||||
(await command.unifiedAnalyticsUsageValues('bundle')).eventData['buildBundleTargetPlatform'],
|
||||
'android-arm',
|
||||
);
|
||||
});
|
||||
|
||||
testUsingContext(
|
||||
|
@ -496,7 +496,6 @@ flutter:
|
||||
final PackagesCommand command = await runCommandIn(projectPath, 'get');
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
expect((await getCommand.usageValues).commandPackagesNumberPlugins, 0);
|
||||
expect(
|
||||
(await getCommand.unifiedAnalyticsUsageValues(
|
||||
'pub/get',
|
||||
@ -535,7 +534,6 @@ flutter:
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
// A plugin example depends on the plugin itself, and integration_test.
|
||||
expect((await getCommand.usageValues).commandPackagesNumberPlugins, 2);
|
||||
expect(
|
||||
(await getCommand.unifiedAnalyticsUsageValues(
|
||||
'pub/get',
|
||||
@ -566,7 +564,6 @@ flutter:
|
||||
final PackagesCommand command = await runCommandIn(projectPath, 'get');
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
expect((await getCommand.usageValues).commandPackagesProjectModule, false);
|
||||
expect(
|
||||
(await getCommand.unifiedAnalyticsUsageValues(
|
||||
'pub/get',
|
||||
@ -600,7 +597,6 @@ flutter:
|
||||
final PackagesCommand command = await runCommandIn(projectPath, 'get');
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
expect((await getCommand.usageValues).commandPackagesProjectModule, true);
|
||||
expect(
|
||||
(await getCommand.unifiedAnalyticsUsageValues(
|
||||
'pub/get',
|
||||
@ -631,7 +627,6 @@ flutter:
|
||||
final PackagesCommand command = await runCommandIn(projectPath, 'get');
|
||||
final PackagesGetCommand getCommand = command.subcommands['get']! as PackagesGetCommand;
|
||||
|
||||
expect((await getCommand.usageValues).commandPackagesAndroidEmbeddingVersion, 'v2');
|
||||
expect(
|
||||
(await getCommand.unifiedAnalyticsUsageValues(
|
||||
'pub/get',
|
||||
|
Loading…
x
Reference in New Issue
Block a user