Skip to content

Commit

Permalink
[tool,web] track web-renderer, and Wasm build args in analytics (#125336
Browse files Browse the repository at this point in the history
)

Addresses part of #125164
  • Loading branch information
kevmoo committed Apr 21, 2023
1 parent f86b922 commit 702f014
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
22 changes: 21 additions & 1 deletion packages/flutter_tools/lib/src/web/compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -222,3 +225,20 @@ const Map<WebRendererMode, Map<NullSafetyMode, HostArtifact>> kDartSdkJsMapArtif
};

const String kWasmPreviewUri = 'https://flutter.dev/wasm';

String _buildEventAnalyticsSettings({
required WebCompilerConfig config,
required BuildInfo buildInfo,
}) {
final Map<String, Object> values = <String, Object>{
...config.buildEventAnalyticsValues,
'web-renderer': buildInfo.webRenderer.cliName,
};

final List<String> sortedList = values.entries
.map((MapEntry<String, Object> e) => '${e.key}: ${e.value};')
.toList()
..sort();

return sortedList.join(' ');
}
14 changes: 14 additions & 0 deletions packages/flutter_tools/lib/src/web/compiler_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ abstract class WebCompilerConfig {
bool get isWasm;

Map<String, String> toBuildSystemEnvironment();

Map<String, Object> get buildEventAnalyticsValues => <String, Object>{
'wasm-compile': isWasm,
};
}

/// Configuration for the Dart-to-Javascript compiler (dart2js).
Expand Down Expand Up @@ -165,4 +169,14 @@ class WasmCompilerConfig extends WebCompilerConfig {
List<String> toCommandOptions() => <String>[
if (omitTypeChecks) '--omit-type-checks',
];

@override
Map<String, Object> get buildEventAnalyticsValues => <String, Object>{
...super.buildEventAnalyticsValues,
for (MapEntry<String, String> entry in toBuildSystemEnvironment()
.entries
.where(
(MapEntry<String, String> element) => element.value == 'true'))
entry.key: entry.value,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;')
),
]));

Expand Down

0 comments on commit 702f014

Please sign in to comment.