Closed GrantAnt closed 2 years ago
Small update. I try to set the user like this:
\Sentry\configureScope(function (\Sentry\State\Scope $scope) {
$scope->setUser(['email' => 'jane.doe@example.com']);
});
When I set to user in 'CakeSentry.Client.afterSetup' Event, it's succesfully shown. When I set to user in 'CakeSentry.Client.beforeCapture' Event, it's not shown at all.
But I need to read the user from the request, which is not available in the ''afterSetup"
I found the solution. It just needs an update in the readme file. Tags and the user can be set like this:
class SentryOptionsContext implements EventListenerInterface
{
public function implementedEvents(): array
{
return [
'CakeSentry.Client.beforeCapture' => 'setContext',
];
}
public function setContext(Event $event): void
{
$event->getSubject()->getHub()->configureScope(function (\Sentry\State\Scope $scope) {
$scope->setUser(['email' => 'jane.doe@example.com']);
});
}
}
I have tried multiple ways to add scope after Sentry::init(). The new tags are not showing up.
e.g.: I am calling this from in my AppController->before
or I have been implementing certain EventListenerInterface and set the tags there. They never show up.
So I got curios and tried to add a new tag in my
app.php
and the test tag was shown immediately!!Versions: