27
27
use Sentry \Breadcrumb ;
28
28
use Sentry \SentrySdk ;
29
29
use Sentry \State \Scope ;
30
+ use Symfony \Component \Console \Input \ArgvInput ;
31
+ use Symfony \Component \Console \Input \ArrayInput ;
32
+ use Symfony \Component \Console \Input \InputInterface ;
30
33
31
34
class EventHandler
32
35
{
@@ -568,9 +571,9 @@ protected function commandStartingHandler(CommandStarting $event)
568
571
Breadcrumb::TYPE_DEFAULT ,
569
572
'artisan.command ' ,
570
573
'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
+ ]
574
577
));
575
578
}
576
579
}
@@ -588,11 +591,10 @@ protected function commandFinishedHandler(CommandFinished $event)
588
591
Breadcrumb::TYPE_DEFAULT ,
589
592
'artisan.command ' ,
590
593
'Finished Artisan command: ' . $ event ->command ,
591
- array_merge ( [
594
+ [
592
595
'exit ' => $ event ->exitCode ,
593
- ], method_exists ($ event ->input , '__toString ' ) ? [
594
- 'input ' => (string )$ event ->input ,
595
- ] : [])
596
+ 'input ' => $ this ->extractCommandInput ($ event ->input ),
597
+ ]
596
598
));
597
599
}
598
600
@@ -604,6 +606,16 @@ protected function commandFinishedHandler(CommandFinished $event)
604
606
Integration::flushEvents ();
605
607
}
606
608
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
+
607
619
protected function octaneRequestReceivedHandler (Octane \RequestReceived $ event ): void
608
620
{
609
621
$ this ->prepareScopeForOctane ();
0 commit comments