From 4651922be6a59b27d7fad479758ff3689d8faa43 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Fri, 2 Dec 2022 23:55:00 +0100 Subject: [PATCH] Update Sentry Laravel SDK --- app/Exceptions/Handler.php | 9 +++++---- composer.json | 2 +- composer.lock | 33 +++++++++++++++++++-------------- config/sentry.php | 5 ++--- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 95f41705f6f4..2dd52187620c 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -32,6 +32,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Facades\Schema; use Illuminate\Validation\ValidationException; use PDOException; +use Sentry\Laravel\Integration; use Sentry\State\Scope; use Swift_TransportException; use Symfony\Component\Console\Exception\CommandNotFoundException; @@ -84,7 +85,7 @@ class Handler extends ExceptionHandler } if (Ninja::isHosted() && ! ($exception instanceof ValidationException)) { - app('sentry')->configureScope(function (Scope $scope): void { + Integration::configureScope(function (Scope $scope): void { $name = 'hosted@invoiceninja.com'; if (auth()->guard('contact') && auth()->guard('contact')->user()) { @@ -104,9 +105,9 @@ class Handler extends ExceptionHandler ]); }); - app('sentry')->captureException($exception); + Integration::captureUnhandledException($exception); } elseif (app()->bound('sentry') && $this->shouldReport($exception)) { - app('sentry')->configureScope(function (Scope $scope): void { + Integration::configureScope(function (Scope $scope): void { if (auth()->guard('contact') && auth()->guard('contact')->user() && auth()->guard('contact')->user()->company->account->report_errors) { $scope->setUser([ 'id' => auth()->guard('contact')->user()->company->account->key, @@ -123,7 +124,7 @@ class Handler extends ExceptionHandler }); if ($this->validException($exception)) { - app('sentry')->captureException($exception); + Integration::captureUnhandledException($exception); } } diff --git a/composer.json b/composer.json index cd79656b2a0f..9f9c9e96f72c 100644 --- a/composer.json +++ b/composer.json @@ -76,7 +76,7 @@ "pragmarx/google2fa": "^8.0", "turbo124/predis": "^1.1", "razorpay/razorpay": "2.*", - "sentry/sentry-laravel": "^2", + "sentry/sentry-laravel": "^3", "setasign/fpdf": "^1.8", "setasign/fpdi": "^2.3", "socialiteproviders/apple": "^5.2", diff --git a/composer.lock b/composer.lock index f11cf2e3a4d8..9605fe477cea 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a27743d9d10e85380cec2a67aeb6d77c", + "content-hash": "451d3dbdd5b0a87940e0f8fffadab4ae", "packages": [ { "name": "afosto/yaac", @@ -8121,37 +8121,42 @@ }, { "name": "sentry/sentry-laravel", - "version": "2.14.2", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-laravel.git", - "reference": "4538ed31d77868dd3b6d72ad6e5e68b572beeb9f" + "reference": "dd55f62a5b7bed0edabc5afcd04e5435713f57ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/4538ed31d77868dd3b6d72ad6e5e68b572beeb9f", - "reference": "4538ed31d77868dd3b6d72ad6e5e68b572beeb9f", + "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/dd55f62a5b7bed0edabc5afcd04e5435713f57ae", + "reference": "dd55f62a5b7bed0edabc5afcd04e5435713f57ae", "shasum": "" }, "require": { - "illuminate/support": "5.0 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0", + "illuminate/support": "^6.0 | ^7.0 | ^8.0 | ^9.0", "nyholm/psr7": "^1.0", "php": "^7.2 | ^8.0", - "sentry/sdk": "^3.1", - "sentry/sentry": "^3.3", + "sentry/sdk": "^3.3", + "sentry/sentry": "^3.10", "symfony/psr-http-message-bridge": "^1.0 | ^2.0" }, + "conflict": { + "laravel/lumen-framework": "*" + }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.11", - "laravel/framework": "5.0 - 5.8 | ^6.0 | ^7.0 | ^8.0 | ^9.0", + "laravel/framework": "^6.0 | ^7.0 | ^8.0 | ^9.0", "mockery/mockery": "^1.3", - "orchestra/testbench": "3.1 - 3.8 | ^4.7 | ^5.1 | ^6.0 | ^7.0", - "phpunit/phpunit": "^5.7 | ^6.5 | ^7.5 | ^8.4 | ^9.3" + "orchestra/testbench": "^4.7 | ^5.1 | ^6.0 | ^7.0", + "phpunit/phpunit": "^8.4 | ^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev", + "dev-master": "3.x-dev", + "dev-2.x": "2.x-dev", + "dev-1.x": "1.x-dev", "dev-0.x": "0.x-dev" }, "laravel": { @@ -8193,7 +8198,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-laravel/issues", - "source": "https://github.com/getsentry/sentry-laravel/tree/2.14.2" + "source": "https://github.com/getsentry/sentry-laravel/tree/3.1.1" }, "funding": [ { @@ -8205,7 +8210,7 @@ "type": "custom" } ], - "time": "2022-10-13T09:21:29+00:00" + "time": "2022-11-14T11:55:52+00:00" }, { "name": "setasign/fpdf", diff --git a/config/sentry.php b/config/sentry.php index 2669e086fa37..d51a346c9033 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -4,8 +4,8 @@ return [ //'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), 'dsn' => config('ninja.sentry_dsn'), - // capture release as git sha - // 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')), + + 'release' => config('ninja.app_version'), 'breadcrumbs' => [ // Capture Laravel logs in breadcrumbs @@ -26,5 +26,4 @@ return [ // @see: https://docs.sentry.io/error-reporting/configuration/?platform=php#send-default-pii 'send_default_pii' => false, - 'release' => config('ninja.app_version'), ];