Unverified Commit 8eee93fa authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Ensure we send hot restart events for flutter web (#40175)

parent c5e2bf5c
......@@ -19,6 +19,7 @@ import '../convert.dart';
import '../device.dart';
import '../globals.dart';
import '../project.dart';
import '../reporting/reporting.dart';
import '../resident_runner.dart';
import '../web/web_device.dart';
import '../web/web_runner.dart';
......@@ -258,6 +259,13 @@ class ResidentWebRunner extends ResidentRunner {
return OperationResult(1, 'Page requires refresh.');
} finally {
status.stop();
HotEvent('restart',
targetPlatform: getNameForTargetPlatform(TargetPlatform.web_javascript),
sdkName: await device.sdkNameAndVersion,
emulator: false,
fullRestart: true,
reason: reason,
).send();
}
}
status.stop();
......
......@@ -12,6 +12,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/build_runner/resident_web_runner.dart';
import 'package:flutter_tools/src/build_runner/web_fs.dart';
......@@ -149,6 +150,12 @@ void main() {
final OperationResult result = await residentWebRunner.restart(fullRestart: false);
expect(result.code, 0);
// ensure that analytics are sent.
verify(Usage.instance.sendEvent('hot', 'restart', parameters: <String, String>{
'cd27': 'web-javascript', 'cd28': null, 'cd29': 'false', 'cd30': 'true'
})).called(1);
}, overrides: <Type, Generator>{
Usage: () => MockFlutterUsage(),
}));
test('Can hot restart after attaching', () => testbed.run(() async {
......@@ -167,6 +174,12 @@ void main() {
final OperationResult result = await residentWebRunner.restart(fullRestart: true);
expect(result.code, 0);
// ensure that analytics are sent.
verify(Usage.instance.sendEvent('hot', 'restart', parameters: <String, String>{
'cd27': 'web-javascript', 'cd28': null, 'cd29': 'false', 'cd30': 'true'
})).called(1);
}, overrides: <Type, Generator>{
Usage: () => MockFlutterUsage(),
}));
test('Fails on compilation errors in hot restart', () => testbed.run(() async {
......@@ -394,6 +407,7 @@ void main() {
}));
}
class MockFlutterUsage extends Mock implements Usage {}
class MockWebDevice extends Mock implements ChromeDevice {}
class MockBuildDaemonCreator extends Mock implements BuildDaemonCreator {}
class MockFlutterWebFs extends Mock implements WebFs {}
......
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