123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\NewRelicReporting\Model\Observer;
- use Magento\Framework\Event\Observer;
- use Magento\Framework\Event\ObserverInterface;
- use Magento\NewRelicReporting\Model\Config;
- use Magento\NewRelicReporting\Model\NewRelicWrapper;
- /**
- * Class ReportConcurrentAdminsToNewRelic
- */
- class ReportConcurrentAdminsToNewRelic implements ObserverInterface
- {
- /**
- * @var Config
- */
- protected $config;
- /**
- * @var \Magento\Backend\Model\Auth\Session
- */
- protected $backendAuthSession;
- /**
- * @var NewRelicWrapper
- */
- protected $newRelicWrapper;
- /**
- * @param Config $config
- * @param \Magento\Backend\Model\Auth\Session $backendAuthSession
- * @param NewRelicWrapper $newRelicWrapper
- */
- public function __construct(
- Config $config,
- \Magento\Backend\Model\Auth\Session $backendAuthSession,
- NewRelicWrapper $newRelicWrapper
- ) {
- $this->config = $config;
- $this->backendAuthSession = $backendAuthSession;
- $this->newRelicWrapper = $newRelicWrapper;
- }
- /**
- * Adds New Relic custom parameters per adminhtml request for current admin user, if applicable
- *
- * @param Observer $observer
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function execute(Observer $observer)
- {
- if ($this->config->isNewRelicEnabled()) {
- if ($this->backendAuthSession->isLoggedIn()) {
- $user = $this->backendAuthSession->getUser();
- $this->newRelicWrapper->addCustomParameter(Config::ADMIN_USER_ID, $user->getId());
- $this->newRelicWrapper->addCustomParameter(Config::ADMIN_USER, $user->getUserName());
- $this->newRelicWrapper->addCustomParameter(
- Config::ADMIN_NAME,
- $user->getFirstName() . ' ' . $user->getLastName()
- );
- }
- }
- }
- }
|