How can I add the usercontext (ie user -id and user email )
robov opened this issue · comments
robov commented
How can I add the usercontext (ie user -id and user email ) to the sentry call ?
Paweł Derehajło commented
As a quick workaround I am simply overriding init() function in my own Component and use it instead
<?php
namespace common\components;
use mito\sentry\Component;
class SentryComponent extends Component
{
public function init()
{
parent::init();
if (!\Yii::$app->user->isGuest) {
$user = \yii::$app->user->identity;
$this->client->user_context(
[
'id' => (string)$user->_id,
'username' => $user->username,
'email' => $user->email,
'ip_address' => $user->ip
]
);
}
}
}
robov commented
Maybe a very wierd or stupid question, but it seems that I get this following error, where this code used to work. What am I missing here?
Call to a member function user_context() on array
$sentry = Yii::$app->get('sentry'); $sentry->client->user_context([
Nikola Kovacs commented
If the component is disabled, client
is not initialized, it remains a configuration array.
robov commented
AWESOME !!!
thank you... !