Skip to content

Instantly share code, notes, and snippets.

@duellsy
Created August 26, 2015 23:36
Show Gist options
  • Save duellsy/8e23b65b4d91aa19775d to your computer and use it in GitHub Desktop.
Save duellsy/8e23b65b4d91aa19775d to your computer and use it in GitHub Desktop.
Using Rollbar in Laravel
// this is in app/Exceptions/Handler.php
// rollbar/rollbar installed via composer
public function report(Exception $e)
{
if (!Config::get('app.debug') && $e->getStatusCode() != '404') {
$conf = [
'access_token' => Config::get('services.rollbar.access_token'),
'environment' => App::environment(),
'root' => app_path(),
'code_version' => Html::gitVersion() // custom method that gets us the current git version
];
if (Auth::check()) {
// add in the user info if available, to contact them if need be
$conf['person'] = [
'id' => Auth::user()->id,
'email' => Auth::user()->email
];
}
Rollbar::init($conf);
Rollbar::report_exception($e);
}
return parent::report($e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment