[ DartDev / CLI ] Fixed issue where analytics flags were not being forwarded to the CLI

Forwarding logic seems to have been accidentally removed in
f3fe9dc3b3392a5e5442535c9fe265fbfc977d15.

Fixes https://github.com/dart-lang/sdk/issues/44968

TEST=pkg/dartdev/test/analytics_test.dart

Fixed: 44968
Change-Id: Ib3c107233276ca6592247e23268f9af7ede52285
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184502
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
diff --git a/pkg/dartdev/test/analytics_test.dart b/pkg/dartdev/test/analytics_test.dart
index 8c74972..6158b0d 100644
--- a/pkg/dartdev/test/analytics_test.dart
+++ b/pkg/dartdev/test/analytics_test.dart
@@ -20,6 +20,33 @@
 void main() {
   group('DisabledAnalytics', disabledAnalyticsObject);
 
+  test('Analytics control smoke test', () {
+    final p = project(logAnalytics: true);
+    var result = p.runSync(['--disable-analytics']);
+    expect(result.stdout, contains('''
+  ╔════════════════════════════════════════════════════════════════════════════╗
+  ║ Anonymous analytics reporting disabled. In order to enable it, run:        ║
+  ║                                                                            ║
+  ║   dart --enable-analytics                                                  ║
+  ║                                                                            ║
+  ╚════════════════════════════════════════════════════════════════════════════╝
+'''));
+
+    result = p.runSync(['--enable-analytics']);
+    expect(result.stdout, contains('''
+  ╔════════════════════════════════════════════════════════════════════════════╗
+  ║ The Dart tool uses Google Analytics to anonymously report feature usage    ║
+  ║ statistics and to send basic crash reports. This data is used to help      ║
+  ║ improve the Dart platform and tools over time.                             ║
+  ║                                                                            ║
+  ║ To disable reporting of anonymous analytics, run:                          ║
+  ║                                                                            ║
+  ║   dart --disable-analytics                                                 ║
+  ║                                                                            ║
+  ╚════════════════════════════════════════════════════════════════════════════╝
+'''));
+  });
+
   group('Sending analytics', () {
     test('help', () {
       final p = project(logAnalytics: true);
diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc
index 517029d..68c2543 100644
--- a/runtime/bin/main_options.cc
+++ b/runtime/bin/main_options.cc
@@ -517,7 +517,8 @@
     // The analytics flags are a special case as we don't have a target script
     // or DartDev command but we still want to launch DartDev.
     DartDevIsolate::set_should_run_dart_dev(true);
-
+    dart_options->AddArgument(enable_dartdev_analytics ? "--enable-analytics"
+                                                       : "--disable-analytics");
     return true;
   }