niclasleonbock /
hacktoberfest-status
| 1 | <?php |
||
| 2 | namespace App\Http\Middleware; |
||
| 3 | |||
| 4 | use Closure; |
||
| 5 | |||
| 6 | class SetSentryContext |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * Handle an incoming request. |
||
| 10 | * |
||
| 11 | * @param \Illuminate\Http\Request $request |
||
| 12 | * @param \Closure $next |
||
| 13 | * |
||
| 14 | * @return mixed |
||
| 15 | */ |
||
| 16 | public function handle($request, Closure $next) |
||
| 17 | { |
||
| 18 | if (!app()->environment('local') && app()->bound('sentry')) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 19 | /** @var \Raven_Client $sentry */ |
||
| 20 | $sentry = app('sentry'); |
||
| 21 | |||
| 22 | // Add user context |
||
| 23 | if (auth()->check()) { |
||
| 24 | $user = auth()->user(); |
||
| 25 | |||
| 26 | $sentry->user_context([ |
||
| 27 | 'github_username' => $user->github_username, |
||
| 28 | 'github_id' => $user->github_id, |
||
| 29 | 'github_token' => str_limit($user->github_token, 8), |
||
| 30 | ]); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | return $next($request); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |