mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
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
This commit is contained in:
parent
ceec48785a
commit
041755faad
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user