I made middle ware for setting customize tag of login user, I want to customize tag in event Id for performance monitering.But this is not working I’m I missing something?? Need Help…
<?php
namespace AppHttpMiddleware;
use Auth;
use Closure;
use SentryStateScope;
class SentryUser
{
/**
* Handle an incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if(Auth::check() && app()->bound('sentry'))
{
SentryconfigureScope(function (Scope $scope): void {
$scope->setTag([
'id' => Auth::user()->id,
'email' => Auth::user()->email,
'name' => Auth::user()->name,
]);
});
}
return $next($request);
}
}
2
Answers
Have you tried setTags instead of setTag?
The
setTag
method is used to set a single tag, while thesetTags
method is used to set multiple tags.Therefore, to set multiple tags in your SentryUser middleware, you should use the
setTags
method, as shown below:You can also use the
setTag
method to set a single tag, as shown below: