Issues (5)

app/Http/Middleware/SetSentryContext.php (1 issue)

Severity
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
The method environment() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        if (!app()->/** @scrutinizer ignore-call */ environment('local') && app()->bound('sentry')) {
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