Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sentry #236

Merged
merged 4 commits into from
May 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Handler extends ExceptionHandler
*/
public function report(Exception $exception)
{
if ($this->shouldReport($exception)) {
app('sentry')->captureException($exception);
}
return parent::report($exception);
}

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"guzzlehttp/guzzle": "^6.1",
"sabre/uri": "1.0.*",
"webmozart/json": "1.0.*",
"jenssegers/rollbar": "^1.4.5"
"jenssegers/rollbar": "^1.4.5",
"sentry/sentry-laravel": "^0.3.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand All @@ -39,7 +40,6 @@
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
Expand Down
2 changes: 2 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
Barryvdh\Debugbar\ServiceProvider::class,
Illuminate\Html\HtmlServiceProvider::class,
Jenssegers\Rollbar\RollbarServiceProvider::class,
Sentry\SentryLaravel\SentryLaravelServiceProvider::class,

/*
* Application Service Providers...
Expand Down Expand Up @@ -200,6 +201,7 @@
'Debugbar' => Barryvdh\Debugbar\Facade::class,
'Form' => Illuminate\Html\FormFacade::class,
'HTML' => Illuminate\Html\HtmlFacade::class,
'Sentry' => Sentry\SentryLaravel\SentryFacade::class,

],

Expand Down
8 changes: 8 additions & 0 deletions config/sentry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return array(
'dsn' => env('SENTRY_DSN'),

// capture release as git sha
// 'release' => trim(exec('git log --pretty="%h" -n1 HEAD')),
);
21 changes: 21 additions & 0 deletions tests/Exceptions/HandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,25 @@ public function testReport()

$this->assertEquals(null, $result);
}

/**
* Report Exception
*
* Information:
* We can not provide better testing for Handler::report()
* because parent::report() do not return anything.
* Ref: Illuminate\Foundation\Exceptions\Handler
*/
public function testReportWithException()
{
$log = Mockery::mock('Illuminate\Log\Writer');
$log->shouldReceive('error');
$handler = new Handler($log);

$exception = new Exception('My test exception');

$result = $handler->report($exception);

$this->assertEquals(null, $result);
}
}