Skip to content

Commit 1abf129

Browse files
jcollins-gCommit Queue
authored and
Commit Queue
committed
Enable crash reporting via the unified_analytics consent mechanism.
This pulls in the `okToSend` method from dart-lang/tools#79 in the tools repository. Bug: #28633 Change-Id: I512d041750050338699d3635ba426cc0acdd5a20 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295380 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Janice Collins <[email protected]> Auto-Submit: Janice Collins <[email protected]>
1 parent 9a6b637 commit 1abf129

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

DEPS

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ vars = {
172172
"test_descriptor_rev": "aa11162f55a93fc6cefc927c5189b5f74decb957",
173173
"test_process_rev": "946bc27abd9726c4dadb9afae7c56f55df5945ed",
174174
"test_reflective_loader_rev": "a85a930ad3736f93b96f6cc104d3576c1ae19e0e",
175-
"tools_rev": "58d914764eab030bf537c2c58089c8ba7b46a313",
175+
"tools_rev": "2308c672e0d7446f5bfdba96594b41f26fa24a2e",
176176
"typed_data_rev": "d85363d2efb333afce07ec409a529ec32986e1a2",
177177
"usage_rev": "0698711985b332432ce9a901bbbd3b1ed227b090",
178178
"vector_math_rev": "7dec98433b3e016fbe49107ad4320b31f519eb70",

pkg/analysis_server/lib/src/analytics/noop_analytics.dart

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class NoopAnalytics implements Analytics {
1111
@override
1212
String get getConsentMessage => throw UnimplementedError();
1313

14+
@override
15+
bool get okToSend => false;
16+
1417
@override
1518
Map<String, ToolInfo> get parsedTools => throw UnimplementedError();
1619

pkg/analysis_server/lib/src/server/driver.dart

+26-25
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,38 @@ class Driver implements ServerStarter {
207207
analytics.setSessionValue('cd1', analysisServerOptions.clientVersion);
208208
}
209209

210+
final defaultSdkPath = _getSdkPath(results);
211+
final dartSdkManager = DartSdkManager(defaultSdkPath);
212+
213+
// TODO(brianwilkerson) It would be nice to avoid creating an SDK that
214+
// can't be re-used, but the SDK is needed to create a package map provider
215+
// in the case where we need to run `pub` in order to get the package map.
216+
var defaultSdk = _createDefaultSdk(defaultSdkPath);
217+
218+
// Create the analytics manager.
219+
AnalyticsManager analyticsManager;
220+
if (disableAnalyticsForSession) {
221+
analyticsManager = AnalyticsManager(NoopAnalytics());
222+
} else {
223+
// TODO(jcollins): implement a full map of `clientId`s to tools to cover
224+
// more analyzer entry points than vscode.
225+
if (clientId == 'VS-Code') {
226+
analyticsManager = AnalyticsManager(_createAnalytics(
227+
defaultSdk, defaultSdkPath, DashTool.vscodePlugins));
228+
} else {
229+
analyticsManager = AnalyticsManager(NoopAnalytics());
230+
}
231+
}
232+
210233
bool shouldSendCallback() {
211234
// Check sdkConfig to optionally force reporting on.
212235
if (sdkConfig.crashReportingForceEnabled == true) {
213236
return true;
214237
}
215238

216-
// TODO(devoncarew): Replace with a real enablement check.
217-
return false;
239+
// Reuse the unified_analytics consent mechanism to determine whether
240+
// we can send a crash report.
241+
return analyticsManager.analytics.okToSend;
218242
}
219243

220244
// Crash reporting
@@ -249,29 +273,6 @@ class Driver implements ServerStarter {
249273
return;
250274
}
251275

252-
final defaultSdkPath = _getSdkPath(results);
253-
final dartSdkManager = DartSdkManager(defaultSdkPath);
254-
255-
// TODO(brianwilkerson) It would be nice to avoid creating an SDK that
256-
// can't be re-used, but the SDK is needed to create a package map provider
257-
// in the case where we need to run `pub` in order to get the package map.
258-
var defaultSdk = _createDefaultSdk(defaultSdkPath);
259-
260-
// Create the analytics manager.
261-
AnalyticsManager analyticsManager;
262-
if (disableAnalyticsForSession) {
263-
analyticsManager = AnalyticsManager(NoopAnalytics());
264-
} else {
265-
// TODO(jcollins): implement a full map of `clientId`s to tools to cover
266-
// more analyzer entry points than vscode.
267-
if (clientId == 'VS-Code') {
268-
analyticsManager = AnalyticsManager(_createAnalytics(
269-
defaultSdk, defaultSdkPath, DashTool.vscodePlugins));
270-
} else {
271-
analyticsManager = AnalyticsManager(NoopAnalytics());
272-
}
273-
}
274-
275276
// Record the start of the session.
276277
analyticsManager.startUp(
277278
time: sessionStartTime,

0 commit comments

Comments
 (0)