From 742351020da59b83d59eb6f436926cc525c77677 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 28 Mar 2024 15:04:34 +0000 Subject: [PATCH] Apply fixes from StyleCI --- Model/SentryInteraction.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Model/SentryInteraction.php b/Model/SentryInteraction.php index 290a44d..257e3ed 100644 --- a/Model/SentryInteraction.php +++ b/Model/SentryInteraction.php @@ -6,9 +6,6 @@ // phpcs:disable Magento2.Functions.DiscouragedFunction -use function Sentry\captureException; -use function Sentry\configureScope; -use function Sentry\init; use Magento\Authorization\Model\UserContextInterface; use Magento\Backend\Model\Auth\Session as AdminSession; use Magento\Customer\Model\Session as CustomerSession; @@ -17,12 +14,17 @@ use Magento\Framework\Exception\LocalizedException; use Sentry\State\Scope; +use function Sentry\captureException; +use function Sentry\configureScope; +use function Sentry\init; + class SentryInteraction { public function __construct( private UserContextInterface $userContext, private State $appState - ) { } + ) { + } public function initialize($config) { @@ -49,10 +51,10 @@ private function getSessionUserData() if ($this->appState->getAreaCode() === Area::AREA_ADMINHTML) { $adminSession = $objectManager->get(AdminSession::class); - if($adminSession->isLoggedIn()) { + if ($adminSession->isLoggedIn()) { return [ - 'id' => $adminSession->getUser()->getId(), - 'email' => $adminSession->getUser()->getEmail(), + 'id' => $adminSession->getUser()->getId(), + 'email' => $adminSession->getUser()->getEmail(), 'user_type' => UserContextInterface::USER_TYPE_ADMIN, ]; } @@ -61,13 +63,13 @@ private function getSessionUserData() if ($this->appState->getAreaCode() === Area::AREA_FRONTEND) { $customerSession = $objectManager->get(CustomerSession::class); - if($customerSession->loggedIn()) { + if ($customerSession->loggedIn()) { return [ - 'id' => $customerSession->getCustomer()->getId(), - 'email' => $customerSession->getCustomer()->getEmail(), + 'id' => $customerSession->getCustomer()->getId(), + 'email' => $customerSession->getCustomer()->getEmail(), 'website_id' => $customerSession->getCustomer()->getWebsiteId(), 'store_id' => $customerSession->getCustomer()->getStoreId(), - 'user_type' => UserContextInterface::USER_TYPE_CUSTOMER, + 'user_type' => UserContextInterface::USER_TYPE_CUSTOMER, ]; } } @@ -80,6 +82,7 @@ public function addUserContext() $userId = null; $userType = null; $userData = []; + try { $userId = $this->userContext->getUserId(); if ($userId) { @@ -100,7 +103,7 @@ public function addUserContext() $scope->setUser([ 'id' => $userId, ...$userData, - 'user_type' => match($userType) { + 'user_type' => match ($userType) { UserContextInterface::USER_TYPE_INTEGRATION => 'integration', UserContextInterface::USER_TYPE_ADMIN => 'admin', UserContextInterface::USER_TYPE_CUSTOMER => 'customer',