Page MenuHomeDevCentral

D2935.diff
No OneTemporary

D2935.diff

diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -2,8 +2,6 @@
namespace Nasqueron\Notifications\Exceptions;
-use Nasqueron\Notifications\Facades\Raven;
-
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
@@ -58,7 +56,7 @@
* Determines if the error handler should report to Sentry
*/
protected function shouldReportToSentry () : bool {
- return Raven::isConfigured() && Config::get('app.env') !== 'testing';
+ return app()->bound('sentry') && Config::get('app.env') !== 'testing';
}
/**
@@ -67,7 +65,7 @@
* @param Exception $e The exception to report
*/
protected function reportToSentry (Exception $e) : void {
- Raven::captureException($e);
+ app('sentry')->captureException($e);
}
}
diff --git a/app/Facades/Raven.php b/app/Facades/Raven.php
deleted file mode 100644
--- a/app/Facades/Raven.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-namespace Nasqueron\Notifications\Facades;
-
-use Illuminate\Support\Facades\Config;
-use Illuminate\Support\Facades\Facade;
-
-/**
- * @see \Raven_Client
- */
-class Raven extends Facade {
-
- /**
- * Gets the registered name of the component.
- */
- protected static function getFacadeAccessor() : string {
- return 'raven';
- }
-
- /**
- * Determines if a Sentry DSN is provided in the configuration
- */
- public static function isConfigured () : bool {
- return Config::get('services.sentry.dsn') !== null;
- }
-}
diff --git a/app/Providers/SentryServiceProvider.php b/app/Providers/SentryServiceProvider.php
deleted file mode 100644
--- a/app/Providers/SentryServiceProvider.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-namespace Nasqueron\Notifications\Providers;
-
-use Illuminate\Contracts\Foundation\Application;
-use Illuminate\Support\ServiceProvider;
-
-class SentryServiceProvider extends ServiceProvider {
-
- /**
- * Bootstraps the application services.
- */
- public function boot() : void {
- }
-
- /**
- * Registers the application services.
- */
- public function register() : void {
- $this->app->singleton('raven', function (Application $app) {
- $config = $app->make('config');
- $dsn = $config->get('services.sentry.dsn');
- return new \Raven_Client($dsn);
- });
- }
-}
diff --git a/composer.json b/composer.json
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,7 @@
"keruald/broker": "^0.5.0",
"keruald/mailgun": "^0.1.0",
"netresearch/jsonmapper": "^1.1.1",
- "sentry/sentry": "^0.13.0"
+ "sentry/sentry-laravel": "^3.2"
},
"require-dev": {
"laravel/browser-kit-testing": "^v6.3.0",
diff --git a/config/app.php b/config/app.php
--- a/config/app.php
+++ b/config/app.php
@@ -193,7 +193,6 @@
Nasqueron\Notifications\Providers\PhabricatorProjectsMapServiceProvider::class,
Nasqueron\Notifications\Providers\ReportServiceProvider::class,
Nasqueron\Notifications\Providers\RouteServiceProvider::class,
- Nasqueron\Notifications\Providers\SentryServiceProvider::class,
Nasqueron\Notifications\Providers\ServicesServiceProvider::class
],
@@ -255,7 +254,6 @@
'Mailgun' => Nasqueron\Notifications\Facades\Mailgun::class,
'PhabricatorAPI' => Nasqueron\Notifications\Facades\PhabricatorAPI::class,
'ProjectsMap' => Nasqueron\Notifications\Facades\ProjectsMap::class,
- 'Raven' => Nasqueron\Notifications\Facades\Raven::class,
'Report' => Nasqueron\Notifications\Facades\Report::class,
'Services' => Nasqueron\Notifications\Facades\Services::class,
diff --git a/config/logging.php b/config/logging.php
new file mode 100644
--- /dev/null
+++ b/config/logging.php
@@ -0,0 +1,122 @@
+<?php
+
+use Monolog\Handler\NullHandler;
+use Monolog\Handler\StreamHandler;
+use Monolog\Handler\SyslogUdpHandler;
+
+return [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Default Log Channel
+ |--------------------------------------------------------------------------
+ |
+ | This option defines the default log channel that gets used when writing
+ | messages to the logs. The name specified in this option should match
+ | one of the channels defined in the "channels" configuration array.
+ |
+ */
+
+ 'default' => env('LOG_CHANNEL', 'stack'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Deprecations Log Channel
+ |--------------------------------------------------------------------------
+ |
+ | This option controls the log channel that should be used to log warnings
+ | regarding deprecated PHP and library features. This allows you to get
+ | your application ready for upcoming major versions of dependencies.
+ |
+ */
+
+ 'deprecations' => [
+ 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
+ 'trace' => false,
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Log Channels
+ |--------------------------------------------------------------------------
+ |
+ | Here you may configure the log channels for your application. Out of
+ | the box, Laravel uses the Monolog PHP logging library. This gives
+ | you a variety of powerful log handlers / formatters to utilize.
+ |
+ | Available Drivers: "single", "daily", "slack", "syslog",
+ | "errorlog", "monolog",
+ | "custom", "stack"
+ |
+ */
+
+ 'channels' => [
+ 'stack' => [
+ 'driver' => 'stack',
+ 'channels' => ['single'],
+ 'ignore_exceptions' => false,
+ ],
+
+ 'single' => [
+ 'driver' => 'single',
+ 'path' => storage_path('logs/laravel.log'),
+ 'level' => env('LOG_LEVEL', 'debug'),
+ ],
+
+ 'daily' => [
+ 'driver' => 'daily',
+ 'path' => storage_path('logs/laravel.log'),
+ 'level' => env('LOG_LEVEL', 'debug'),
+ 'days' => 14,
+ ],
+
+ 'slack' => [
+ 'driver' => 'slack',
+ 'url' => env('LOG_SLACK_WEBHOOK_URL'),
+ 'username' => 'Laravel Log',
+ 'emoji' => ':boom:',
+ 'level' => env('LOG_LEVEL', 'critical'),
+ ],
+
+ 'papertrail' => [
+ 'driver' => 'monolog',
+ 'level' => env('LOG_LEVEL', 'debug'),
+ 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
+ 'handler_with' => [
+ 'host' => env('PAPERTRAIL_URL'),
+ 'port' => env('PAPERTRAIL_PORT'),
+ 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
+ ],
+ ],
+
+ 'stderr' => [
+ 'driver' => 'monolog',
+ 'level' => env('LOG_LEVEL', 'debug'),
+ 'handler' => StreamHandler::class,
+ 'formatter' => env('LOG_STDERR_FORMATTER'),
+ 'with' => [
+ 'stream' => 'php://stderr',
+ ],
+ ],
+
+ 'syslog' => [
+ 'driver' => 'syslog',
+ 'level' => env('LOG_LEVEL', 'debug'),
+ ],
+
+ 'errorlog' => [
+ 'driver' => 'errorlog',
+ 'level' => env('LOG_LEVEL', 'debug'),
+ ],
+
+ 'null' => [
+ 'driver' => 'monolog',
+ 'handler' => NullHandler::class,
+ ],
+
+ 'emergency' => [
+ 'path' => storage_path('logs/laravel.log'),
+ ],
+ ],
+
+];
diff --git a/config/sentry.php b/config/sentry.php
new file mode 100644
--- /dev/null
+++ b/config/sentry.php
@@ -0,0 +1,116 @@
+<?php
+
+return [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Sentry DSN
+ |--------------------------------------------------------------------------
+ |
+ | This option controls the DSN to reach Sentry Relay server.
+ |
+ */
+
+ 'dsn' => env('SENTRY_DSN'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Sentry release version
+ |--------------------------------------------------------------------------
+ |
+ | This option controls the release version of the application.
+ |
+ | Example with dynamic git hash:
+ | trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
+ |
+ */
+
+ 'release' => env('SENTRY_RELEASE'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Sentry environment
+ |--------------------------------------------------------------------------
+ |
+ | This option controls the release version of the application.
+ |
+ | When left empty or `null` the Laravel environment will be used.
+ |
+ */
+
+ 'environment' => env('SENTRY_ENVIRONMENT'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Sentry breadcrumbs
+ |
+ | Determines the scope of w hat's capturd in breadcrumbs.
+ |--------------------------------------------------------------------------
+ |
+ */
+
+ 'breadcrumbs' => [
+ 'logs' => true,
+ 'sql_queries' => true,
+ 'sql_bindings' => true,
+ 'queue_info' => true,
+ 'command_info' => true,
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Sentry tracing
+ |
+ | This option controls what's traced or captured as spans.
+ |
+ | See https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#traces-sample-rate
+ | for the sample rate.
+ |--------------------------------------------------------------------------
+ |
+ */
+
+ 'tracing' => [
+ // Trace queue jobs as their own transactions
+ 'queue_job_transactions' => env('SENTRY_TRACE_QUEUE_ENABLED', false),
+
+ // Capture queue jobs as spans when executed on the sync driver
+ 'queue_jobs' => true,
+
+ // Capture SQL queries as spans
+ 'sql_queries' => true,
+
+ // Try to find out where the SQL query originated from and add it to the query spans
+ 'sql_origin' => true,
+
+ // Capture views as spans
+ 'views' => true,
+
+ // Capture HTTP client requests as spans
+ 'http_client_requests' => true,
+
+ // Indicates if the tracing integrations supplied by Sentry should be loaded
+ 'default_integrations' => true,
+
+ // Indicates that requests without a matching route should be traced
+ 'missing_routes' => false,
+ ],
+
+ 'traces_sample_rate' => env('SENTRY_TRACES_SAMPLE_RATE') === null ? null : (float)env('SENTRY_TRACES_SAMPLE_RATE'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Sentry PII
+ |
+ | This option controls if Personal Identifiable Information (PII) should
+ | be sent to the Relay or scrubbed here.
+ |
+ | If set at true, PII can still be removed in Relay or Sentry itself.
+ |
+ | See https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#send-default-pii
+ |--------------------------------------------------------------------------
+ |
+ */
+
+ 'send_default_pii' => env('SENTRY_SEND_DEFAULT_PII', false),
+
+];
diff --git a/config/services.php b/config/services.php
--- a/config/services.php
+++ b/config/services.php
@@ -35,10 +35,6 @@
'secret' => env('STRIPE_SECRET'),
],
- 'sentry' => [
- 'dsn' => env('SENTRY_DSN'),
- ],
-
'dockerhub' => [
'tokens' => env('DOCKERHUB_TOKENS', 'DockerHubTokens.json')
],
diff --git a/tests/Exceptions/HandlerTest.php b/tests/Exceptions/HandlerTest.php
--- a/tests/Exceptions/HandlerTest.php
+++ b/tests/Exceptions/HandlerTest.php
@@ -5,6 +5,8 @@
use Nasqueron\Notifications\Exceptions\Handler;
use Nasqueron\Notifications\Tests\TestCase;
+use Sentry\State\HubInterface;
+
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Support\Facades\Config;
use Mockery;
@@ -17,36 +19,36 @@
private $handler;
/**
- * Raven_Client
+ * Sentry client
*/
- private $ravenClientMock;
+ private HubInterface $sentryClientMock;
public function setUp (): void {
parent::setUp();
$this->handler = new Handler($this->app);
- $this->mockRavenClient();
+ $this->mockSentryClient();
}
- protected function mockRavenClient () {
+ protected function mockSentryClient () {
// Inject into our container a mock of Raven_Client
- $this->ravenClientMock = Mockery::mock('Raven_Client');
- $this->app->instance('raven', $this->ravenClientMock);
+ $this->sentryClientMock = Mockery::mock(HubInterface::class);
+ $this->app->instance('sentry', $this->sentryClientMock);
// Environment shouldn't be 'testing' and DSN should be defined,
- // so Handler::report will call Raven to report to Sentry
+ // so Handler::report will call Sentry to report to Sentry
Config::set('app.env', 'testing-raven');
Config::set('services.sentry.dsn', 'mock');
}
- public function testRavenReport () {
- $this->ravenClientMock->shouldReceive('captureException')->once();
+ public function tesSentryReport () {
+ $this->sentryClientMock->shouldReceive('captureException')->once();
$this->handler->report(new \Exception);
}
public function testExceptionInDontReportArray () {
- $this->ravenClientMock->shouldReceive('captureException')->never();
+ $this->sentryClientMock->shouldReceive('captureException')->never();
$this->handler->report(new AuthorizationException);
}
}
diff --git a/tests/Facades/RavenTest.php b/tests/Facades/RavenTest.php
deleted file mode 100644
--- a/tests/Facades/RavenTest.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace Nasqueron\Notifications\Tests\Facades;
-
-use Nasqueron\Notifications\Tests\TestCase;
-use Nasqueron\Notifications\Facades\Raven;
-
-use Illuminate\Support\Facades\Config;
-
-class RavenTest extends TestCase {
-
- public function testIfFacadeAccessorCouldBeResolvedInAppContainer () {
- $this->assertInstanceOf(
- 'Raven_Client',
- Raven::getFacadeRoot()
- );
- }
-
- public function testIsConfigured () {
- Config::set("services.sentry.dsn", "something");
- $this->assertTrue(Raven::isConfigured());
- }
-
- public function testIsConfiguredWhenItIsNot () {
- Config::offsetUnset("services.sentry.dsn");
- $this->assertFalse(Raven::isConfigured());
- }
-
-}
diff --git a/tests/Providers/SentryServiceProviderTest.php b/tests/Providers/SentryServiceProviderTest.php
deleted file mode 100644
--- a/tests/Providers/SentryServiceProviderTest.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-namespace Nasqueron\Notifications\Tests\Providers;
-
-class SentryServiceProviderTest extends TestCase {
-
- public function testType () {
- $this->assertServiceInstanceOf(
- 'Raven_Client',
- 'raven'
- );
- }
-
-}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 03:25 (18 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2307326
Default Alt Text
D2935.diff (15 KB)

Event Timeline