@@ -84,10 +84,10 @@ final class Cli {
8484 (sentryDsn == null
8585 ? ctx.httpClient
8686 : SentryHttpClient (client: ctx.httpClient));
87- ctx.performance = ( sentryDsn == null ||
88- io.Platform .environment.containsKey ('CELEST_NO_ANALYTICS' ) )
89- ? const CelestPerformance ()
90- : const SentryPerformance ();
87+ ctx.performance = sentryDsn != null &&
88+ ! io.Platform .environment.containsKey ('CELEST_NO_ANALYTICS' )
89+ ? const SentryPerformance ()
90+ : const CelestPerformance ();
9191 ctx.storage = storage ?? Storage ();
9292
9393 try {
@@ -114,18 +114,14 @@ final class Cli {
114114 ctx.secureStorage = NativeMemoryStorage (namespace: Storage .cliNamespace);
115115 }
116116
117- ctx.analytics = postHogConfig == null ||
118- io.Platform .environment.containsKey ('CELEST_NO_ANALYTICS' )
119- ? const NoopAnalytics ()
120- : PostHog (
117+ ctx.analytics = postHogConfig != null &&
118+ ! io.Platform .environment.containsKey ('CELEST_NO_ANALYTICS' )
119+ ? PostHog (
121120 config: postHogConfig,
122121 client: ctx.httpClient,
123122 storage: ctx.secureStorage,
124- );
125-
126- if (kReleaseMode) {
127- ctx.analytics.identifyUser (setOnce: {'local_iterations_mvp' : true });
128- }
123+ )
124+ : const NoopAnalytics ();
129125
130126 final sdkFinder = DartSdkFinder (
131127 platform: ctx.platform,
@@ -225,6 +221,8 @@ final class Cli {
225221 );
226222 },
227223 appRunner: () => _run (argResults),
224+ // We use our own error handling, so we don't want to use the default
225+ // `runZonedGuarded` behavior.
228226 // ignore: invalid_use_of_internal_member
229227 callAppRunnerInRunZonedGuarded: false ,
230228 );
@@ -359,6 +357,13 @@ final class Cli {
359357 }
360358
361359 Future <void > _handleError (Object error, StackTrace stackTrace) async {
360+ Future <void > recordError () async {
361+ await ctx.performance
362+ .innerCaptureError (error, stackTrace: stackTrace)
363+ .timeout (const Duration (seconds: 3 ))
364+ .catchError ((_) => '' );
365+ }
366+
362367 switch (error) {
363368 case UsageException ():
364369 stderr.writeln (error);
@@ -374,13 +379,15 @@ final class Cli {
374379 ..writeln (stackTrace);
375380 }
376381 exitCode = 1 ;
382+ await recordError ();
377383 default :
378384 _logFile
379385 ? ..writeln (error)
380386 ..writeln (stackTrace);
381387 ctx.cliLogger
382388 ..err (error.toString ())
383389 ..detail (stackTrace.toString ());
390+ await recordError ();
384391 }
385392 }
386393
@@ -393,6 +400,7 @@ final class Cli {
393400 await _loggerSub? .cancel ();
394401 await _logFile? .flush ();
395402 await _logFile? .close ();
403+ await ctx.performance.close ();
396404 ctx.httpClient.close ();
397405 exit (exitCode);
398406 }
0 commit comments