skip to Main Content

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


  1. Have you tried setTags instead of setTag?

    Login or Signup to reply.
  2. The setTag method is used to set a single tag, while the setTags 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:

    SentryconfigureScope(function (SentryStateScope $scope): void {
        $scope->setTags([
            'id'    => Auth::user()->id,
            'email' => Auth::user()->email,
            'name'  => Auth::user()->name,
        ]);
    });
    

    You can also use the setTag method to set a single tag, as shown below:

    SentryconfigureScope(function (SentryStateScope $scope): void {
        $scope->setTag('id', Auth::user()->id); 
        $scope->setTag('email', Auth::user()->email); 
        $scope->setTag('name', Auth::user()->name); 
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search