Add analytics tracking for compile and refresh times for Flutter Web (#41545)
This commit is contained in:
@@ -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(),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user