From 702f0144e0998d031b59c0042e5380c1ae0fab8f Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 21 Apr 2023 16:09:00 -0700 Subject: [PATCH] [tool,web] track web-renderer, and Wasm build args in analytics (#125336) Addresses part of https://github.com/flutter/flutter/issues/125164 --- .../flutter_tools/lib/src/web/compile.dart | 22 ++++++++++++++++++- .../lib/src/web/compiler_config.dart | 14 ++++++++++++ .../general.shard/web/compile_web_test.dart | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/web/compile.dart b/packages/flutter_tools/lib/src/web/compile.dart index cfd09632cd..ab09203110 100644 --- a/packages/flutter_tools/lib/src/web/compile.dart +++ b/packages/flutter_tools/lib/src/web/compile.dart @@ -129,7 +129,10 @@ class WebBuilder { BuildEvent( 'web-compile', type: 'web', - settings: 'wasm-compile: ${compilerConfig.isWasm}', + settings: _buildEventAnalyticsSettings( + config: compilerConfig, + buildInfo: buildInfo, + ), flutterUsage: _flutterUsage, ).send(); @@ -222,3 +225,20 @@ const Map> kDartSdkJsMapArtif }; const String kWasmPreviewUri = 'https://flutter.dev/wasm'; + +String _buildEventAnalyticsSettings({ + required WebCompilerConfig config, + required BuildInfo buildInfo, +}) { + final Map values = { + ...config.buildEventAnalyticsValues, + 'web-renderer': buildInfo.webRenderer.cliName, + }; + + final List sortedList = values.entries + .map((MapEntry e) => '${e.key}: ${e.value};') + .toList() + ..sort(); + + return sortedList.join(' '); +} diff --git a/packages/flutter_tools/lib/src/web/compiler_config.dart b/packages/flutter_tools/lib/src/web/compiler_config.dart index 32dd39563f..754dff24b4 100644 --- a/packages/flutter_tools/lib/src/web/compiler_config.dart +++ b/packages/flutter_tools/lib/src/web/compiler_config.dart @@ -11,6 +11,10 @@ abstract class WebCompilerConfig { bool get isWasm; Map toBuildSystemEnvironment(); + + Map get buildEventAnalyticsValues => { + 'wasm-compile': isWasm, + }; } /// Configuration for the Dart-to-Javascript compiler (dart2js). @@ -165,4 +169,14 @@ class WasmCompilerConfig extends WebCompilerConfig { List toCommandOptions() => [ if (omitTypeChecks) '--omit-type-checks', ]; + + @override + Map get buildEventAnalyticsValues => { + ...super.buildEventAnalyticsValues, + for (MapEntry entry in toBuildSystemEnvironment() + .entries + .where( + (MapEntry element) => element.value == 'true')) + entry.key: entry.value, + }; } diff --git a/packages/flutter_tools/test/general.shard/web/compile_web_test.dart b/packages/flutter_tools/test/general.shard/web/compile_web_test.dart index b166425f53..f90ce9fec6 100644 --- a/packages/flutter_tools/test/general.shard/web/compile_web_test.dart +++ b/packages/flutter_tools/test/general.shard/web/compile_web_test.dart @@ -88,7 +88,7 @@ void main() { 'build', 'web', label: 'web-compile', - parameters: CustomDimensions(buildEventSettings: 'wasm-compile: true') + parameters: CustomDimensions(buildEventSettings: 'wasm-compile: true; web-renderer: auto;') ), ]));