Skip to content

Commit 18cd8bc

Browse files
committed
Merge pull request #9 from tremby/user-data-processor
Provide an optional user data processor
2 parents df78fca + acf5403 commit 18cd8bc

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Clowdy\Raven\Processors;
4+
5+
use Auth;
6+
7+
class UserDataProcessor
8+
{
9+
public function __invoke(array $record)
10+
{
11+
if ($user = Auth::user()) {
12+
$record['context']['user'] = $user->toArray();
13+
} else {
14+
$record['context']['user'] = ['id' => null];
15+
}
16+
return $record;
17+
}
18+
}

src/config/config.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@
7777
*/
7878

7979
'processors' => [
80-
// 'Monolog\Processor\GitProcessor'
80+
// Uncomment the following line to include user data from Auth
81+
// 'Clowdy\Raven\Processors\UserDataProcessor',
82+
83+
// Use a built-in Monolog processor
84+
// 'Monolog\Processor\GitProcessor',
8185
],
8286

8387
],

0 commit comments

Comments
 (0)