Skip to content

Commit 702f014

Browse files
authored
[tool,web] track web-renderer, and Wasm build args in analytics (#125336)
Addresses part of flutter/flutter#125164
1 parent f86b922 commit 702f014

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

packages/flutter_tools/lib/src/web/compile.dart

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ class WebBuilder {
129129
BuildEvent(
130130
'web-compile',
131131
type: 'web',
132-
settings: 'wasm-compile: ${compilerConfig.isWasm}',
132+
settings: _buildEventAnalyticsSettings(
133+
config: compilerConfig,
134+
buildInfo: buildInfo,
135+
),
133136
flutterUsage: _flutterUsage,
134137
).send();
135138

@@ -222,3 +225,20 @@ const Map<WebRendererMode, Map<NullSafetyMode, HostArtifact>> kDartSdkJsMapArtif
222225
};
223226

224227
const String kWasmPreviewUri = 'https://flutter.dev/wasm';
228+
229+
String _buildEventAnalyticsSettings({
230+
required WebCompilerConfig config,
231+
required BuildInfo buildInfo,
232+
}) {
233+
final Map<String, Object> values = <String, Object>{
234+
...config.buildEventAnalyticsValues,
235+
'web-renderer': buildInfo.webRenderer.cliName,
236+
};
237+
238+
final List<String> sortedList = values.entries
239+
.map((MapEntry<String, Object> e) => '${e.key}: ${e.value};')
240+
.toList()
241+
..sort();
242+
243+
return sortedList.join(' ');
244+
}

packages/flutter_tools/lib/src/web/compiler_config.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ abstract class WebCompilerConfig {
1111
bool get isWasm;
1212

1313
Map<String, String> toBuildSystemEnvironment();
14+
15+
Map<String, Object> get buildEventAnalyticsValues => <String, Object>{
16+
'wasm-compile': isWasm,
17+
};
1418
}
1519

1620
/// Configuration for the Dart-to-Javascript compiler (dart2js).
@@ -165,4 +169,14 @@ class WasmCompilerConfig extends WebCompilerConfig {
165169
List<String> toCommandOptions() => <String>[
166170
if (omitTypeChecks) '--omit-type-checks',
167171
];
172+
173+
@override
174+
Map<String, Object> get buildEventAnalyticsValues => <String, Object>{
175+
...super.buildEventAnalyticsValues,
176+
for (MapEntry<String, String> entry in toBuildSystemEnvironment()
177+
.entries
178+
.where(
179+
(MapEntry<String, String> element) => element.value == 'true'))
180+
entry.key: entry.value,
181+
};
168182
}

packages/flutter_tools/test/general.shard/web/compile_web_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void main() {
8888
'build',
8989
'web',
9090
label: 'web-compile',
91-
parameters: CustomDimensions(buildEventSettings: 'wasm-compile: true')
91+
parameters: CustomDimensions(buildEventSettings: 'wasm-compile: true; web-renderer: auto;')
9292
),
9393
]));
9494

0 commit comments

Comments
 (0)