Unverified Commit aa9a1151 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Move reporting files to reporting/ (#36017)

Slight cleanup of file locations in flutter_tools
to make it easier to see which files are responsible
for data reporting.
parent 540c7476
......@@ -13,10 +13,10 @@ import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/disabled_usage.dart';
import 'package:flutter_tools/src/bundle.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/reporting/disabled_usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
const String _kOptionPackages = 'packages';
const String _kOptionAsset = 'asset-dir';
......
......@@ -16,12 +16,12 @@ import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/disabled_usage.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/disabled_usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:flutter_tools/src/test/coverage_collector.dart';
import 'package:flutter_tools/src/test/runner.dart';
import 'package:flutter_tools/src/usage.dart';
// This was largely inspired by lib/src/commands/test.dart.
......
......@@ -17,12 +17,12 @@ import 'src/base/logger.dart';
import 'src/base/process.dart';
import 'src/base/utils.dart';
import 'src/context_runner.dart';
import 'src/crash_reporting.dart';
import 'src/doctor.dart';
import 'src/globals.dart';
import 'src/reporting/crash_reporting.dart';
import 'src/reporting/usage.dart';
import 'src/runner/flutter_command.dart';
import 'src/runner/flutter_command_runner.dart';
import 'src/usage.dart';
import 'src/version.dart';
/// Runs the Flutter tool with support for the specified list of [commands].
......@@ -109,18 +109,19 @@ Future<int> _handleToolError(
stderr.writeln(stackTrace.toString());
return _exit(1);
} else {
flutterUsage.sendException(error, stackTrace);
// Report to both [Usage] and [CrashReportSender].
flutterUsage.sendException(error);
await CrashReportSender.instance.sendReport(
error: error,
stackTrace: stackTrace,
getFlutterVersion: getFlutterVersion,
);
if (error is String)
stderr.writeln('Oops; flutter has exited unexpectedly: "$error".');
else
stderr.writeln('Oops; flutter has exited unexpectedly.');
await CrashReportSender.instance.sendReport(
error: error,
stackTrace: stackTrace,
getFlutterVersion: getFlutterVersion,
);
try {
final File file = await _createLocalCrashReport(args, error, stackTrace);
stderr.writeln(
......
......@@ -22,8 +22,8 @@ import '../cache.dart';
import '../flutter_manifest.dart';
import '../globals.dart';
import '../project.dart';
import '../reporting/usage.dart';
import '../runner/flutter_command.dart';
import '../usage.dart';
import 'android_sdk.dart';
import 'android_studio.dart';
......
......@@ -14,7 +14,8 @@ import '../dart/package_map.dart';
import '../globals.dart';
import '../macos/xcode.dart';
import '../project.dart';
import '../usage.dart';
import '../reporting/usage.dart';
import 'context.dart';
import 'file_system.dart';
import 'fingerprint.dart';
......
......@@ -9,8 +9,8 @@ import '../base/file_system.dart';
import '../build_info.dart';
import '../bundle.dart';
import '../project.dart';
import '../reporting/usage.dart';
import '../runner/flutter_command.dart' show FlutterOptions, FlutterCommandResult;
import '../usage.dart';
import '../version.dart';
import 'build.dart';
......
......@@ -8,8 +8,8 @@ import '../android/android_sdk.dart';
import '../android/android_studio.dart';
import '../convert.dart';
import '../globals.dart';
import '../reporting/usage.dart';
import '../runner/flutter_command.dart';
import '../usage.dart';
class ConfigCommand extends FlutterCommand {
ConfigCommand({ bool verboseHelp = false }) {
......
......@@ -22,9 +22,9 @@ import '../dart/pub.dart';
import '../doctor.dart';
import '../globals.dart';
import '../project.dart';
import '../reporting/usage.dart';
import '../runner/flutter_command.dart';
import '../template.dart';
import '../usage.dart';
import '../version.dart';
enum _ProjectType {
......
......@@ -8,8 +8,8 @@ import '../base/common.dart';
import '../base/os.dart';
import '../dart/pub.dart';
import '../project.dart';
import '../reporting/usage.dart';
import '../runner/flutter_command.dart';
import '../usage.dart';
class PackagesCommand extends FlutterCommand {
PackagesCommand() {
......
......@@ -16,14 +16,15 @@ import '../device.dart';
import '../globals.dart';
import '../macos/xcode.dart';
import '../project.dart';
import '../reporting/usage.dart';
import '../resident_runner.dart';
import '../resident_web_runner.dart';
import '../run_cold.dart';
import '../run_hot.dart';
import '../runner/flutter_command.dart';
import '../tracing.dart';
import '../usage.dart';
import '../version.dart';
import 'daemon.dart';
abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
......
......@@ -41,8 +41,8 @@ import 'macos/cocoapods_validator.dart';
import 'macos/macos_workflow.dart';
import 'macos/xcode.dart';
import 'macos/xcode_validator.dart';
import 'reporting/usage.dart';
import 'run_hot.dart';
import 'usage.dart';
import 'version.dart';
import 'web/chrome.dart';
import 'web/workflow.dart';
......
......@@ -32,8 +32,8 @@ import 'macos/cocoapods_validator.dart';
import 'macos/macos_workflow.dart';
import 'macos/xcode_validator.dart';
import 'proxy_validator.dart';
import 'reporting/usage.dart';
import 'tester/flutter_tester.dart';
import 'usage.dart';
import 'version.dart';
import 'vscode/vscode_validator.dart';
import 'web/web_validator.dart';
......
......@@ -16,7 +16,7 @@ import '../convert.dart';
import '../devfs.dart';
import '../globals.dart';
import '../project.dart';
import '../usage.dart';
import '../reporting/usage.dart';
import 'fuchsia_pm.dart';
import 'fuchsia_sdk.dart';
......
......@@ -24,8 +24,8 @@ import '../globals.dart';
import '../macos/cocoapod_utils.dart';
import '../macos/xcode.dart';
import '../project.dart';
import '../reporting/usage.dart';
import '../services.dart';
import '../usage.dart';
import 'code_signing.dart';
import 'xcodeproj.dart';
......
......@@ -13,7 +13,7 @@ import '../cache.dart';
import '../convert.dart';
import '../globals.dart';
import '../project.dart';
import '../usage.dart';
import '../reporting/usage.dart';
/// Builds the Linux project through the Makefile.
Future<void> buildLinux(LinuxProject linuxProject, BuildInfo buildInfo, {String target = 'lib/main.dart'}) async {
......
......@@ -12,7 +12,8 @@ import '../convert.dart';
import '../globals.dart';
import '../ios/xcodeproj.dart';
import '../project.dart';
import '../usage.dart';
import '../reporting/usage.dart';
import 'cocoapod_utils.dart';
/// Builds the macOS project through xcodebuild.
......
Flutter reports data to two separate systems:
1. Anonymous usage statistics are reported to Google Analytics (for statistics
such as the number of times the `flutter` tool was run within a given time
period). The code that manages this is in [usage.dart].
1. Crash reports for the `flutter` tool. These are not reports of when Flutter
applications crash, but rather when the command-line `flutter` tool itself
crashes. The code that manages this is in [crash_reporting.dart].
## Opting out
Users can opt out of all reporting in a single place by running
`flutter config --no-analytics`.
......@@ -8,10 +8,11 @@ import 'package:http/http.dart' as http;
import 'package:meta/meta.dart';
import 'package:stack_trace/stack_trace.dart';
import 'base/io.dart';
import 'base/os.dart';
import 'base/platform.dart';
import 'globals.dart';
import '../base/io.dart';
import '../base/os.dart';
import '../base/platform.dart';
import '../globals.dart';
import 'usage.dart';
/// Tells crash backend that the error is from the Flutter CLI.
......
......@@ -35,7 +35,7 @@ class DisabledUsage implements Usage {
void sendTiming(String category, String variableName, Duration duration, { String label }) { }
@override
void sendException(dynamic exception, StackTrace trace) { }
void sendException(dynamic exception) { }
@override
Stream<Map<String, dynamic>> get onSend => null;
......
......@@ -7,13 +7,13 @@ import 'dart:async';
import 'package:meta/meta.dart';
import 'package:usage/usage_io.dart';
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/os.dart';
import 'base/platform.dart';
import 'base/utils.dart';
import 'globals.dart';
import 'version.dart';
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/os.dart';
import '../base/platform.dart';
import '../base/utils.dart';
import '../globals.dart';
import '../version.dart';
const String _kFlutterUA = 'UA-67589403-6';
......@@ -152,9 +152,9 @@ class Usage {
}
}
void sendException(dynamic exception, StackTrace trace) {
void sendException(dynamic exception) {
if (!suppressAnalytics)
_analytics.sendException('${exception.runtimeType}\n${sanitizeStacktrace(trace)}');
_analytics.sendException(exception.runtimeType.toString());
}
/// Fires whenever analytics data is sent over the network.
......
......@@ -21,8 +21,8 @@ import 'convert.dart';
import 'devfs.dart';
import 'device.dart';
import 'globals.dart';
import 'reporting/usage.dart';
import 'resident_runner.dart';
import 'usage.dart';
import 'vmservice.dart';
class HotRunnerConfig {
......
......@@ -27,7 +27,7 @@ import '../device.dart';
import '../doctor.dart';
import '../globals.dart';
import '../project.dart';
import '../usage.dart';
import '../reporting/usage.dart';
import '../version.dart';
import 'flutter_command_runner.dart';
......
......@@ -30,8 +30,8 @@ import '../convert.dart';
import '../dart/package_map.dart';
import '../device.dart';
import '../globals.dart';
import '../reporting/usage.dart';
import '../tester/flutter_tester.dart';
import '../usage.dart';
import '../version.dart';
import '../vmservice.dart';
......
......@@ -13,7 +13,7 @@ import '../build_info.dart';
import '../bundle.dart';
import '../globals.dart';
import '../project.dart';
import '../usage.dart';
import '../reporting/usage.dart';
/// The [WebCompilationProxy] instance.
WebCompilationProxy get webCompilationProxy => context.get<WebCompilationProxy>();
......
......@@ -13,7 +13,8 @@ import '../cache.dart';
import '../convert.dart';
import '../globals.dart';
import '../project.dart';
import '../usage.dart';
import '../reporting/usage.dart';
import 'msbuild_utils.dart';
import 'visual_studio.dart';
......
......@@ -13,7 +13,7 @@ import 'package:flutter_tools/src/commands/config.dart';
import 'package:flutter_tools/src/commands/doctor.dart';
import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:flutter_tools/src/version.dart';
import '../src/common.dart';
......
......@@ -7,7 +7,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_bundle.dart';
import 'package:flutter_tools/src/bundle.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
......
......@@ -7,7 +7,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import '../../src/common.dart';
import '../../src/testbed.dart';
......
......@@ -18,7 +18,7 @@ import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/proxy_validator.dart';
import 'package:flutter_tools/src/vscode/vscode.dart';
import 'package:flutter_tools/src/vscode/vscode_validator.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import '../../src/common.dart';
import '../../src/context.dart';
......
......@@ -10,7 +10,7 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/packages.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:process/process.dart';
import '../../src/common.dart';
......
......@@ -17,7 +17,7 @@ import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/crash_reporting.dart';
import 'package:flutter_tools/src/reporting/crash_reporting.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:pedantic/pedantic.dart';
......
......@@ -8,9 +8,9 @@ import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/run_hot.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:json_rpc_2/json_rpc_2.dart';
import 'package:mockito/mockito.dart';
......
......@@ -4,7 +4,7 @@
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/base/time.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/version.dart';
......
......@@ -5,7 +5,7 @@
import 'dart:async';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:mockito/mockito.dart';
......
......@@ -21,7 +21,7 @@ import 'package:flutter_tools/src/ios/simulators.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/base/time.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
......@@ -302,7 +302,7 @@ class MockUsage implements Usage {
void sendTiming(String category, String variableName, Duration duration, { String label }) { }
@override
void sendException(dynamic exception, StackTrace trace) { }
void sendException(dynamic exception) { }
@override
Stream<Map<String, dynamic>> get onSend => null;
......
......@@ -16,7 +16,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/usage.dart';
import 'package:flutter_tools/src/reporting/usage.dart';
import 'package:flutter_tools/src/version.dart';
import 'context.dart';
......@@ -164,7 +164,7 @@ class NoOpUsage implements Usage {
void sendEvent(String category, String parameter,{ Map<String, String> parameters }) {}
@override
void sendException(dynamic exception, StackTrace trace) {}
void sendException(dynamic exception) {}
@override
void sendTiming(String category, String variableName, Duration duration, { String label }) {}
......
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