Skip to content

Commit

Permalink
Tiny refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive committed Oct 12, 2022
1 parent 8602d6c commit 2754355
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/Sentry/Laravel/EventHandler.php
Expand Up @@ -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),
]
));
}
Expand All @@ -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;
Expand Down

0 comments on commit 2754355

Please sign in to comment.