Commit eb3c70ee authored by Mark Harding's avatar Mark Harding

(chore): log mobile users with sentry

parent b3937061
No related merge requests found
Pipeline #77849065 passed with stages
in 17 minutes and 1 second
<?php
namespace Minds\Core\OAuth\Repositories\Delegates;
use Sentry;
use Minds\Core\OAuth\Entities\UserEntity;
class SentryScopeDelegate
{
/**
* Pass through a user guid to sentry
* @param UserEntity $entity
* @return void
*/
public function onGetUserEntity(UserEntity $entity): void
{
Sentry\configureScope(function (Sentry\State\Scope $scope) use ($entity): void {
$scope->setUser([
'id' => (string) $entity->getIdentifier(),
]);
});
}
}
......@@ -15,12 +15,16 @@ class UserRepository implements UserRepositoryInterface
/** @var Password $password */
private $password;
/** @var SentryScopeDelegate $sentryScopeDelegate */
private $sentryScopeDelegate;
/** @var User $mock */
public $mockUser = false;
public function __construct(Password $password = null)
public function __construct(Password $password = null, SentryScopeDelegate $sentryScopeDelegate = null)
{
$this->password = $password ?: Di::_()->get('Security\Password');
$this->sentryScopeDelegate = $sentryScopeDelegate ?? new Delegates\SentryScopeDelegate;
}
/**
......@@ -52,6 +56,10 @@ class UserRepository implements UserRepositoryInterface
$entity = new UserEntity();
$entity->setIdentifier($user->getGuid());
// Update Sentry scope with our user
$this->sentryScopeDelegate->onGetUserEntity($entity);
return $entity;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment