Skip to content

Commit 2bb80f9

Browse files
stayalliveHazAT
authored andcommitted
Track Artisan command invocation in breadcrumb (#232)
* Track artisan command invocation in breadcrumb * Update changelog
1 parent 7426daf commit 2bb80f9

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Track Artisan command invocation in breadcrumb (#232)
56
- Fixed `sql_bindings` configuration fallback (#231)
67
- Fixed events generated in queue worker not sending until worker exits (#228)
78
- Add phpDoc methods to the facade for better autocompletion (#226)

src/Sentry/Laravel/EventHandler.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,21 @@ protected function queueJobProcessingHandler(JobProcessing $event)
313313
*/
314314
protected function commandStartingHandler(CommandStarting $event)
315315
{
316-
Integration::configureScope(function (Scope $scope) use ($event): void {
317-
if ($event->command) {
316+
if ($event->command) {
317+
Integration::configureScope(function (Scope $scope) use ($event): void {
318318
$scope->setTag('command', $event->command);
319-
}
320-
});
319+
});
320+
321+
Integration::addBreadcrumb(new Breadcrumb(
322+
Breadcrumb::LEVEL_INFO,
323+
Breadcrumb::TYPE_USER,
324+
'artisan.command',
325+
'Invoked Artisan command: ' . $event->command,
326+
method_exists($event->input, '__toString') ? [
327+
'input' => (string)$event->input,
328+
] : []
329+
));
330+
}
321331
}
322332

323333
/**

0 commit comments

Comments
 (0)