mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:31:57 +00:00
Enable crash reporting via the unified_analytics consent mechanism.
This pulls in the `okToSend` method from https://github.com/dart-lang/tools/pull/79 in the tools repository. Bug: https://github.com/dart-lang/sdk/issues/28633 Change-Id: I512d041750050338699d3635ba426cc0acdd5a20 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295380 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Janice Collins <jcollins@google.com> Auto-Submit: Janice Collins <jcollins@google.com>
This commit is contained in:
parent
9a6b637444
commit
1abf129bf8
2
DEPS
2
DEPS
|
@ -172,7 +172,7 @@ vars = {
|
|||
"test_descriptor_rev": "aa11162f55a93fc6cefc927c5189b5f74decb957",
|
||||
"test_process_rev": "946bc27abd9726c4dadb9afae7c56f55df5945ed",
|
||||
"test_reflective_loader_rev": "a85a930ad3736f93b96f6cc104d3576c1ae19e0e",
|
||||
"tools_rev": "58d914764eab030bf537c2c58089c8ba7b46a313",
|
||||
"tools_rev": "2308c672e0d7446f5bfdba96594b41f26fa24a2e",
|
||||
"typed_data_rev": "d85363d2efb333afce07ec409a529ec32986e1a2",
|
||||
"usage_rev": "0698711985b332432ce9a901bbbd3b1ed227b090",
|
||||
"vector_math_rev": "7dec98433b3e016fbe49107ad4320b31f519eb70",
|
||||
|
|
|
@ -11,6 +11,9 @@ class NoopAnalytics implements Analytics {
|
|||
@override
|
||||
String get getConsentMessage => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
bool get okToSend => false;
|
||||
|
||||
@override
|
||||
Map<String, ToolInfo> get parsedTools => throw UnimplementedError();
|
||||
|
||||
|
|
|
@ -207,14 +207,38 @@ class Driver implements ServerStarter {
|
|||
analytics.setSessionValue('cd1', analysisServerOptions.clientVersion);
|
||||
}
|
||||
|
||||
final defaultSdkPath = _getSdkPath(results);
|
||||
final dartSdkManager = DartSdkManager(defaultSdkPath);
|
||||
|
||||
// TODO(brianwilkerson) It would be nice to avoid creating an SDK that
|
||||
// can't be re-used, but the SDK is needed to create a package map provider
|
||||
// in the case where we need to run `pub` in order to get the package map.
|
||||
var defaultSdk = _createDefaultSdk(defaultSdkPath);
|
||||
|
||||
// Create the analytics manager.
|
||||
AnalyticsManager analyticsManager;
|
||||
if (disableAnalyticsForSession) {
|
||||
analyticsManager = AnalyticsManager(NoopAnalytics());
|
||||
} else {
|
||||
// TODO(jcollins): implement a full map of `clientId`s to tools to cover
|
||||
// more analyzer entry points than vscode.
|
||||
if (clientId == 'VS-Code') {
|
||||
analyticsManager = AnalyticsManager(_createAnalytics(
|
||||
defaultSdk, defaultSdkPath, DashTool.vscodePlugins));
|
||||
} else {
|
||||
analyticsManager = AnalyticsManager(NoopAnalytics());
|
||||
}
|
||||
}
|
||||
|
||||
bool shouldSendCallback() {
|
||||
// Check sdkConfig to optionally force reporting on.
|
||||
if (sdkConfig.crashReportingForceEnabled == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO(devoncarew): Replace with a real enablement check.
|
||||
return false;
|
||||
// Reuse the unified_analytics consent mechanism to determine whether
|
||||
// we can send a crash report.
|
||||
return analyticsManager.analytics.okToSend;
|
||||
}
|
||||
|
||||
// Crash reporting
|
||||
|
@ -249,29 +273,6 @@ class Driver implements ServerStarter {
|
|||
return;
|
||||
}
|
||||
|
||||
final defaultSdkPath = _getSdkPath(results);
|
||||
final dartSdkManager = DartSdkManager(defaultSdkPath);
|
||||
|
||||
// TODO(brianwilkerson) It would be nice to avoid creating an SDK that
|
||||
// can't be re-used, but the SDK is needed to create a package map provider
|
||||
// in the case where we need to run `pub` in order to get the package map.
|
||||
var defaultSdk = _createDefaultSdk(defaultSdkPath);
|
||||
|
||||
// Create the analytics manager.
|
||||
AnalyticsManager analyticsManager;
|
||||
if (disableAnalyticsForSession) {
|
||||
analyticsManager = AnalyticsManager(NoopAnalytics());
|
||||
} else {
|
||||
// TODO(jcollins): implement a full map of `clientId`s to tools to cover
|
||||
// more analyzer entry points than vscode.
|
||||
if (clientId == 'VS-Code') {
|
||||
analyticsManager = AnalyticsManager(_createAnalytics(
|
||||
defaultSdk, defaultSdkPath, DashTool.vscodePlugins));
|
||||
} else {
|
||||
analyticsManager = AnalyticsManager(NoopAnalytics());
|
||||
}
|
||||
}
|
||||
|
||||
// Record the start of the session.
|
||||
analyticsManager.startUp(
|
||||
time: sessionStartTime,
|
||||
|
|
Loading…
Reference in a new issue