2727use Sentry \Breadcrumb ;
2828use Sentry \SentrySdk ;
2929use Sentry \State \Scope ;
30+ use Symfony \Component \Console \Input \ArgvInput ;
31+ use Symfony \Component \Console \Input \ArrayInput ;
32+ use Symfony \Component \Console \Input \InputInterface ;
3033
3134class EventHandler
3235{
@@ -568,9 +571,9 @@ protected function commandStartingHandler(CommandStarting $event)
568571 Breadcrumb::TYPE_DEFAULT ,
569572 'artisan.command ' ,
570573 'Starting Artisan command: ' . $ event ->command ,
571- method_exists ( $ event -> input , ' __toString ' ) ? [
572- 'input ' => ( string ) $ event ->input ,
573- ] : []
574+ [
575+ 'input ' => $ this -> extractCommandInput ( $ event ->input ) ,
576+ ]
574577 ));
575578 }
576579 }
@@ -588,11 +591,10 @@ protected function commandFinishedHandler(CommandFinished $event)
588591 Breadcrumb::TYPE_DEFAULT ,
589592 'artisan.command ' ,
590593 'Finished Artisan command: ' . $ event ->command ,
591- array_merge ( [
594+ [
592595 'exit ' => $ event ->exitCode ,
593- ], method_exists ($ event ->input , '__toString ' ) ? [
594- 'input ' => (string )$ event ->input ,
595- ] : [])
596+ 'input ' => $ this ->extractCommandInput ($ event ->input ),
597+ ]
596598 ));
597599 }
598600
@@ -604,6 +606,16 @@ protected function commandFinishedHandler(CommandFinished $event)
604606 Integration::flushEvents ();
605607 }
606608
609+ /** @return string|null */
610+ private function extractCommandInput (InputInterface $ input )
611+ {
612+ if ($ input instanceof ArgvInput) {
613+ return (string )$ input ;
614+ }
615+
616+ return null ;
617+ }
618+
607619 protected function octaneRequestReceivedHandler (Octane \RequestReceived $ event ): void
608620 {
609621 $ this ->prepareScopeForOctane ();
0 commit comments