From 61775822db5b042445c3830676fbd505fbc7ad21 Mon Sep 17 00:00:00 2001 From: Brian Wilkerson Date: Tue, 7 Mar 2023 18:06:20 +0000 Subject: [PATCH] Add a flag to the diagnostic pages to control developer support I would prefer to have the code uncommented because it will help prevent it from becoming stale. Change-Id: I86dc0c715433cbeab33b3739f826475fcc583bc6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287161 Reviewed-by: Keerti Parthasarathy Commit-Queue: Brian Wilkerson --- .../lib/src/status/diagnostics.dart | 80 ++++++++++--------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/pkg/analysis_server/lib/src/status/diagnostics.dart b/pkg/analysis_server/lib/src/status/diagnostics.dart index b92d92ae4ad..64260e120c7 100644 --- a/pkg/analysis_server/lib/src/status/diagnostics.dart +++ b/pkg/analysis_server/lib/src/status/diagnostics.dart @@ -159,44 +159,40 @@ String writeOption(String name, dynamic value) { return '$name: $value
'; } -// TODO(brianwilkerson) This page is disabled for production until we determine -// whether we want to display some information to the user and if so what -// information we want to display. -// -// class AnalyticsPage extends DiagnosticPageWithNav { -// AnalyticsPage(DiagnosticsSite site) -// : super(site, 'analytics', 'Analytics', -// description: 'Analytics gathered by the analysis server.'); -// -// @override -// String? get navDetail => null; -// -// @override -// Future generateContent(Map params) async { -// var manager = server.analyticsManager; -// // -// // Display the standard header. -// // -// if (!manager.analytics.telemetryEnabled) { -// p('Analytics reporting disabled. In order to enable it, run:'); -// p('  dart --enable-analytics'); -// p('If analytics had been enabled, the information below would have been ' -// 'reported.'); -// } else { -// p('The Dart tool uses Google Analytics to report feature usage ' -// 'statistics and to send basic crash reports. This data is used to ' -// 'help improve the Dart platform and tools over time.'); -// p('To disable reporting of analytics, run:'); -// p('  dart --disable-analytics'); -// p('The information below will be reported the next time analytics are ' -// 'sent.'); -// } -// // -// // Display the analytics data that has been gathered. -// // -// manager.toHtml(buf); -// } -// } +class AnalyticsPage extends DiagnosticPageWithNav { + AnalyticsPage(DiagnosticsSite site) + : super(site, 'analytics', 'Analytics', + description: 'Analytics gathered by the analysis server.'); + + @override + String? get navDetail => null; + + @override + Future generateContent(Map params) async { + var manager = server.analyticsManager; + // + // Display the standard header. + // + if (!manager.analytics.telemetryEnabled) { + p('Analytics reporting disabled. In order to enable it, run:'); + p('  dart --enable-analytics'); + p('If analytics had been enabled, the information below would have been ' + 'reported.'); + } else { + p('The Dart tool uses Google Analytics to report feature usage ' + 'statistics and to send basic crash reports. This data is used to ' + 'help improve the Dart platform and tools over time.'); + p('To disable reporting of analytics, run:'); + p('  dart --disable-analytics'); + p('The information below will be reported the next time analytics are ' + 'sent.'); + } + // + // Display the analytics data that has been gathered. + // + manager.toHtml(buf); + } +} class AstPage extends DiagnosticPageWithNav { String? _description; @@ -1010,6 +1006,10 @@ abstract class DiagnosticPageWithNav extends DiagnosticPage { } class DiagnosticsSite extends Site implements AbstractGetHandler { + /// A flag used to control whether developer support should be included when + /// building the pages. + static const bool includeDeveloperSupport = false; + /// An object that can handle either a WebSocket connection or a connection /// to the client over stdio. AbstractSocketServer socketServer; @@ -1024,7 +1024,9 @@ class DiagnosticsSite extends Site implements AbstractGetHandler { pages.add(EnvironmentVariablesPage(this)); pages.add(ExceptionsPage(this)); // pages.add(new InstrumentationPage(this)); - // pages.add(AnalyticsPage(this)); + if (includeDeveloperSupport) { + pages.add(AnalyticsPage(this)); + } // Add server-specific pages. Ordering doesn't matter as the items are // sorted later.