Unverified Commit e8517a43 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Add analytics tracking for compile and refresh times for Flutter Web (#41545)

parent 94993055
......@@ -264,9 +264,17 @@ class ResidentWebRunner extends ResidentRunner {
return OperationResult(1, 'Failed to recompile application.');
}
if (supportsServiceProtocol) {
// Send an event for only recompilation.
final Duration recompileDuration = timer.elapsed;
flutterUsage.sendTiming('hot', 'web-recompile', recompileDuration);
try {
final vmservice.Response reloadResponse = await _vmService.callServiceExtension('hotRestart');
printStatus('Restarted application in ${getElapsedAsMilliseconds(timer.elapsed)}.');
// Send timing analytics for full restart and for refresh.
flutterUsage.sendTiming('hot', 'web-restart', timer.elapsed);
flutterUsage.sendTiming('hot', 'web-refresh', timer.elapsed - recompileDuration);
return reloadResponse.type == 'Success'
? OperationResult.ok
: OperationResult(1, reloadResponse.toString());
......
......@@ -173,7 +173,7 @@ void main() {
connectionInfoCompleter: connectionInfoCompleter,
));
await connectionInfoCompleter.future;
when(mockWebFs.recompile()).thenAnswer((Invocation _) async {
when(mockWebFs.recompile()).thenAnswer((Invocation invocation) async {
return true;
});
when(mockVmService.callServiceExtension('hotRestart')).thenAnswer((Invocation _) async {
......@@ -189,6 +189,9 @@ void main() {
'cd29': 'false',
'cd30': 'true',
})).called(1);
verify(Usage.instance.sendTiming('hot', 'web-restart', any)).called(1);
verify(Usage.instance.sendTiming('hot', 'web-refresh', any)).called(1);
verify(Usage.instance.sendTiming('hot', 'web-recompile', any)).called(1);
}, overrides: <Type, Generator>{
Usage: () => MockFlutterUsage(),
}));
......@@ -200,7 +203,7 @@ void main() {
connectionInfoCompleter: connectionInfoCompleter,
));
await connectionInfoCompleter.future;
when(mockWebFs.recompile()).thenAnswer((Invocation _) async {
when(mockWebFs.recompile()).thenAnswer((Invocation invocation) async {
return true;
});
when(mockVmService.callServiceExtension('hotRestart')).thenAnswer((Invocation _) async {
......@@ -216,6 +219,9 @@ void main() {
'cd29': 'false',
'cd30': 'true',
})).called(1);
verify(Usage.instance.sendTiming('hot', 'web-restart', any)).called(1);
verify(Usage.instance.sendTiming('hot', 'web-refresh', any)).called(1);
verify(Usage.instance.sendTiming('hot', 'web-recompile', any)).called(1);
}, overrides: <Type, Generator>{
Usage: () => MockFlutterUsage(),
}));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment