-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support sentry reporting (#403)
- Loading branch information
Showing
10 changed files
with
1,442 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Closure; | ||
use Sentry\State\Scope; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Route; | ||
|
||
class SentryContext | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \Closure $next | ||
* | ||
* @return mixed | ||
* | ||
* @codeCoverageIgnore | ||
*/ | ||
public function handle($request, Closure $next) | ||
{ | ||
if (app()->bound('sentry') && config('app.sentry.enable')) { | ||
\Sentry\configureScope(function (Scope $scope): void { | ||
// Add user context | ||
$user = Auth::user(); | ||
if ($user !== null) { | ||
$scope->setUser([ | ||
'id' => $user->id, | ||
]); | ||
} | ||
$scope->setTag('page.route.name', Route::currentRouteName()); | ||
$scope->setTag('page.route.action', Route::currentRouteAction()); | ||
}); | ||
} | ||
|
||
return $next($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.