Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #132

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions Model/SentryInteraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand All @@ -49,10 +51,10 @@
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,
];
}
Expand All @@ -61,13 +63,13 @@
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,
];
}
}
Expand All @@ -80,6 +82,7 @@
$userId = null;
$userType = null;
$userData = [];

try {
$userId = $this->userContext->getUserId();
if ($userId) {
Expand All @@ -100,7 +103,7 @@
$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',
Expand All @@ -108,7 +111,7 @@
default => 'unknown'
},
]);
dump($scope->getUser());

Check failure on line 114 in Model/SentryInteraction.php

View workflow job for this annotation

GitHub Actions / analyse

Function dump not found.

Check failure on line 114 in Model/SentryInteraction.php

View workflow job for this annotation

GitHub Actions / analyse

Function dump not found.
});
} catch (\Throwable $e) {
}
Expand Down
Loading