[analysis_server] Report angular plugin exceptions to new staging crash product

Change-Id: I72826fc66ff87acc5003e913483a63081fa2931b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145960
Reviewed-by: Jaime Wren <jwren@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
diff --git a/pkg/analysis_server/lib/src/server/crash_reporting.dart b/pkg/analysis_server/lib/src/server/crash_reporting.dart
index 8b5a118..866b9ff 100644
--- a/pkg/analysis_server/lib/src/server/crash_reporting.dart
+++ b/pkg/analysis_server/lib/src/server/crash_reporting.dart
@@ -8,6 +8,8 @@
 import 'package:analyzer/instrumentation/service.dart';
 import 'package:telemetry/crash_reporting.dart';
 
+const _angularPluginName = 'Angular Analysis Plugin';
+
 class CrashReportingInstrumentation extends NoopInstrumentationService {
   // A staging reporter, that we are in the process of phasing out.
   final CrashReportSender stagingReporter;
@@ -15,7 +17,11 @@
   // A prod reporter, that we are in the process of phasing in.
   final CrashReportSender prodReporter;
 
-  CrashReportingInstrumentation(this.stagingReporter, this.prodReporter);
+  // The angular plugin crash reporter.
+  final CrashReportSender angularReporter;
+
+  CrashReportingInstrumentation(
+      this.stagingReporter, this.prodReporter, this.angularReporter);
 
   @override
   void logException(dynamic exception,
@@ -46,14 +52,14 @@
     dynamic exception,
     StackTrace stackTrace,
   ) {
-    // TODO(devoncarew): Temporarily disabled; re-enable after deciding on a
-    // plan of action for the AngularDart analysis plugin.
-    const angularPluginName = 'Angular Analysis Plugin';
-    if (plugin.name == angularPluginName) {
-      return;
+    if (plugin.name == _angularPluginName) {
+      angularReporter.sendReport(exception, stackTrace).catchError((error) {
+        // We silently ignore errors sending crash reports (network issues, ...).
+      });
+    } else {
+      _sendServerReport(exception, stackTrace,
+          comment: 'plugin: ${plugin.name}');
     }
-
-    _sendServerReport(exception, stackTrace, comment: 'plugin: ${plugin.name}');
   }
 
   void _sendServerReport(Object exception, Object stackTrace,
diff --git a/pkg/analysis_server/lib/src/server/driver.dart b/pkg/analysis_server/lib/src/server/driver.dart
index dc8af62..54245c7 100644
--- a/pkg/analysis_server/lib/src/server/driver.dart
+++ b/pkg/analysis_server/lib/src/server/driver.dart
@@ -407,6 +407,9 @@
         CrashReportSender.staging(crashProductId, shouldSendCallback);
     final crashReportSenderProd =
         CrashReportSender.prod(crashProductId, shouldSendCallback);
+    // TODO(mfairhurst): send these to prod or disable.
+    final crashReportSenderAngular = CrashReportSender.staging(
+        'Dart_angular_analysis_plugin', shouldSendCallback);
 
     if (telemetry.SHOW_ANALYTICS_UI) {
       if (results.wasParsed(ANALYTICS_FLAG)) {
@@ -458,7 +461,9 @@
 
     var errorNotifier = ErrorNotifier();
     allInstrumentationServices.add(CrashReportingInstrumentation(
-        crashReportSenderStaging, crashReportSenderProd));
+        crashReportSenderStaging,
+        crashReportSenderProd,
+        crashReportSenderAngular));
     instrumentationService =
         MulticastInstrumentationService(allInstrumentationServices);