From 27543554a0dc72824632e0cb702ea6f0125d44b7 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Wed, 12 Oct 2022 10:20:40 +0200 Subject: [PATCH] Tiny refactoring --- src/Sentry/Laravel/EventHandler.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Sentry/Laravel/EventHandler.php b/src/Sentry/Laravel/EventHandler.php index 39fccea7..da545049 100644 --- a/src/Sentry/Laravel/EventHandler.php +++ b/src/Sentry/Laravel/EventHandler.php @@ -572,7 +572,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 +593,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;