Unverified Commit 041755fa authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

don't send crash reports if on a user branch (#33078)

* don't send crash reports if on a user branch.
* add test to test/crash_reporting_test.dart
parent ceec4878
......@@ -60,7 +60,7 @@ Future<int> run(
await runner.run(args);
await _exit(0);
} catch (error, stackTrace) {
String getVersion() => flutterVersion ?? FlutterVersion.instance.getVersionString();
String getVersion() => flutterVersion ?? FlutterVersion.instance.getVersionString(redactUnknownBranches: true);
return await _handleToolError(error, stackTrace, verbose, args, reportCrashes, getVersion);
}
return 0;
......
......@@ -86,12 +86,15 @@ class CrashReportSender {
@required String getFlutterVersion(),
}) async {
try {
if (_usage.suppressAnalytics)
final String flutterVersion = getFlutterVersion();
// We don't need to report exceptions happening on user branches
if (_usage.suppressAnalytics || RegExp(r'^\[user-branch\]\/').hasMatch(flutterVersion)) {
return;
}
printStatus('Sending crash report to Google.');
final String flutterVersion = getFlutterVersion();
final Uri uri = _baseUrl.replace(
queryParameters: <String, String>{
'product': _kProductId,
......
......@@ -123,6 +123,39 @@ void main() {
Stdio: () => const _NoStderr(),
});
testUsingContext('should not send a crash report if on a user-branch', () async {
String method;
Uri uri;
CrashReportSender.initializeWith(MockClient((Request request) async {
method = request.method;
uri = request.url;
return Response(
'test-report-id',
200,
);
}));
final int exitCode = await tools.run(
<String>['crash'],
<FlutterCommand>[_CrashCommand()],
reportCrashes: true,
flutterVersion: '[user-branch]/v1.2.3',
);
expect(exitCode, 1);
// Verify that the report wasn't sent
expect(method, null);
expect(uri, null);
final BufferLogger logger = context.get<Logger>();
expect(logger.statusText, '');
}, overrides: <Type, Generator>{
Stdio: () => const _NoStderr(),
});
testUsingContext('can override base URL', () async {
Uri uri;
CrashReportSender.initializeWith(MockClient((Request request) async {
......
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