Skip to content

Commit e637d0e

Browse files
authored
Merge pull request #146 from ejunker/patch-1
Add tag with name of console command
2 parents 856170b + 34fd6ae commit e637d0e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/Sentry/SentryLaravel/SentryLaravelEventHandler.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Illuminate\Routing\Events\RouteMatched;
1111
use Illuminate\Contracts\Events\Dispatcher;
1212
use Illuminate\Database\Events\QueryExecuted;
13+
use Illuminate\Console\Events\CommandStarting;
14+
use Illuminate\Console\Events\CommandFinished;
1315

1416
class SentryLaravelEventHandler
1517
{
@@ -27,6 +29,9 @@ class SentryLaravelEventHandler
2729

2830
'illuminate.log' => 'log', // Until Laravel 5.3
2931
'Illuminate\Log\Events\MessageLogged' => 'messageLogged', // Since Laravel 5.4
32+
33+
'Illuminate\Console\Events\CommandStarting' => 'commandStarting', // Since Laravel 5.5
34+
'Illuminate\Console\Events\CommandFinished' => 'commandFinished', // Since Laravel 5.5
3035
);
3136

3237
/**
@@ -234,4 +239,28 @@ protected function authenticatedHandler(Authenticated $event)
234239
'id' => $event->user->getAuthIdentifier(),
235240
));
236241
}
242+
243+
/**
244+
* Since Laravel 5.5
245+
*
246+
* @param \Illuminate\Console\Events\CommandStarting $event
247+
*/
248+
protected function commandStartingHandler(CommandStarting $event)
249+
{
250+
$this->client->tags_context(array(
251+
'command' => $event->command,
252+
));
253+
}
254+
255+
/**
256+
* Since Laravel 5.5
257+
*
258+
* @param \Illuminate\Console\Events\CommandFinished $event
259+
*/
260+
protected function commandFinishedHandler(CommandFinished $event)
261+
{
262+
$this->client->tags_context(array(
263+
'command' => null,
264+
));
265+
}
237266
}

0 commit comments

Comments
 (0)