Skip to content

Commit 34fd6ae

Browse files
committed
Added CommandFinished as event too
1 parent 973a0f1 commit 34fd6ae

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/Sentry/SentryLaravel/SentryLaravelEventHandler.php

Lines changed: 24 additions & 9 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,8 +29,9 @@ class SentryLaravelEventHandler
2729

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

3437
/**
@@ -225,27 +228,39 @@ protected function messageLoggedHandler(MessageLogged $logEntry)
225228
));
226229
}
227230

231+
/**
232+
* Since Laravel 5.3
233+
*
234+
* @param \Illuminate\Auth\Events\Authenticated $event
235+
*/
236+
protected function authenticatedHandler(Authenticated $event)
237+
{
238+
$this->client->user_context(array(
239+
'id' => $event->user->getAuthIdentifier(),
240+
));
241+
}
242+
228243
/**
229244
* Since Laravel 5.5
230245
*
231-
* @param Illuminate\Console\Events\CommandStarting $event
246+
* @param \Illuminate\Console\Events\CommandStarting $event
232247
*/
233-
protected function commandStartingHandler($event)
248+
protected function commandStartingHandler(CommandStarting $event)
234249
{
235250
$this->client->tags_context(array(
236251
'command' => $event->command,
237252
));
238253
}
239-
254+
240255
/**
241-
* Since Laravel 5.3
256+
* Since Laravel 5.5
242257
*
243-
* @param \Illuminate\Auth\Events\Authenticated $event
258+
* @param \Illuminate\Console\Events\CommandFinished $event
244259
*/
245-
protected function authenticatedHandler(Authenticated $event)
260+
protected function commandFinishedHandler(CommandFinished $event)
246261
{
247-
$this->client->user_context(array(
248-
'id' => $event->user->getAuthIdentifier(),
262+
$this->client->tags_context(array(
263+
'command' => null,
249264
));
250265
}
251266
}

0 commit comments

Comments
 (0)