refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
This commit is contained in:
44
app/Http/Middleware/SentryContext.php
Normal file
44
app/Http/Middleware/SentryContext.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Sentry\State\Scope;
|
||||
use App\Helpers\RequestHelper;
|
||||
|
||||
class SentryContext
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (app()->bound('sentry') && config('monica.sentry_support')) {
|
||||
// Add user context
|
||||
if (auth()->check()) {
|
||||
\Sentry\configureScope(function (Scope $scope): void {
|
||||
$user = auth()->user();
|
||||
$scope->setUser([
|
||||
'id' => $user->id,
|
||||
'email' => $user->email,
|
||||
'username' => $user->name,
|
||||
]);
|
||||
$scope->setExtra('isSubscribed', $user->account->isSubscribed());
|
||||
});
|
||||
} else {
|
||||
\Sentry\configureScope(function (Scope $scope): void {
|
||||
$scope->setUser([
|
||||
'id' => null,
|
||||
'ip_address' => RequestHelper::ip(),
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user