I'm using Sentry Http://GetSentry.com with Laravel 5.1. For various reasons, I'd like to know WHICH of my users caused the exception. The documentation suggests that I only need to pass a second argument to the captureException method. Here's what my [email protected] looks like:
public function report(Exception $e)
{
if ($this->shouldReport($e)) {
$user = Auth::user();
app('sentry')->captureException($e,['user' => ['info' => $user]]);
}
parent::report($e);
}
Sentry support is suggesting that I make a middleware to capture this information and use the user_context method. However it's still not working as expected and I can't see any of the data in the Sentry dashboard.
public function report(Exception $e)
{
if(Auth::user())
{
//dd(Auth::user()->email);
app('sentry')->user_context(array(
'email' => Auth::user()->email
));
}
if ($this->shouldReport($e)) {
$user = Auth::user();
app('sentry')->captureException($e,['user' => ['info' => $user]]);
}
parent::report($e);
}
Yes, I contacted the excellent SEntry support and they helped me. Apparently I was doing error reporting wrong from an earlier version of Sentry and Laravel. The new stuff gives such beautiful error messages and data. Reach out, they're great.