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,20 @@ protected function commandFinishedHandler(CommandFinished $event)
604606 Integration::flushEvents ();
605607 }
606608
609+ /** @return array|string|null */
610+ private function extractCommandInput (InputInterface $ input )
611+ {
612+ $ extracted = null ;
613+
614+ if ($ input instanceof ArgvInput) {
615+ $ extracted = (string )$ input ;
616+ } elseif ($ input instanceof ArrayInput) {
617+ $ extracted = $ input ->getArguments ();
618+ }
619+
620+ return $ extracted ;
621+ }
622+
607623 protected function octaneRequestReceivedHandler (Octane \RequestReceived $ event ): void
608624 {
609625 $ this ->prepareScopeForOctane ();
0 commit comments