diff --git a/src/Sentry/Laravel/EventHandler.php b/src/Sentry/Laravel/EventHandler.php index 39fccea7..5ad15db6 100644 --- a/src/Sentry/Laravel/EventHandler.php +++ b/src/Sentry/Laravel/EventHandler.php @@ -28,7 +28,6 @@ use Sentry\SentrySdk; use Sentry\State\Scope; use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; class EventHandler @@ -572,7 +571,7 @@ protected function commandStartingHandler(CommandStarting $event) 'artisan.command', 'Starting Artisan command: ' . $event->command, [ - 'input' => $this->extractCommandInput($event->input), + 'input' => $this->extractConsoleCommandInput($event->input), ] )); } @@ -593,21 +592,27 @@ protected function commandFinishedHandler(CommandFinished $event) 'Finished Artisan command: ' . $event->command, [ 'exit' => $event->exitCode, - 'input' => $this->extractCommandInput($event->input), + 'input' => $this->extractConsoleCommandInput($event->input), ] )); } - Integration::configureScope(static function (Scope $scope): void { - $scope->setTag('command', ''); - }); - // Flush any and all events that were possibly generated by the command Integration::flushEvents(); + + Integration::configureScope(static function (Scope $scope): void { + $scope->removeTag('command'); + }); } - /** @return string|null */ - private function extractCommandInput(InputInterface $input) + /** + * Extract the command input arguments if possible. + * + * @param \Symfony\Component\Console\Input\InputInterface|null $input + * + * @return string|null + */ + private function extractConsoleCommandInput(?InputInterface $input): ?string { if ($input instanceof ArgvInput) { return (string)$input;