Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReportConcurrentUsersToNewRelic.php
Go to the documentation of this file.
1 <?php
7 
12 
17 {
21  protected $config;
22 
26  protected $customerSession;
27 
32 
36  protected $storeManager;
37 
41  protected $newRelicWrapper;
42 
50  public function __construct(
52  \Magento\Customer\Model\Session $customerSession,
53  \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
54  \Magento\Store\Model\StoreManagerInterface $storeManager,
56  ) {
57  $this->config = $config;
58  $this->customerSession = $customerSession;
59  $this->customerRepository = $customerRepository;
60  $this->storeManager = $storeManager;
61  $this->newRelicWrapper = $newRelicWrapper;
62  }
63 
71  public function execute(Observer $observer)
72  {
73  if ($this->config->isNewRelicEnabled()) {
74  $this->newRelicWrapper->addCustomParameter(Config::STORE, $this->storeManager->getStore()->getName());
75  $this->newRelicWrapper->addCustomParameter(Config::WEBSITE, $this->storeManager->getWebsite()->getName());
76 
77  if ($this->customerSession->isLoggedIn()) {
78  $customer = $this->customerRepository->getById($this->customerSession->getCustomerId());
79  $this->newRelicWrapper->addCustomParameter(Config::CUSTOMER_ID, $customer->getId());
80  $this->newRelicWrapper->addCustomParameter(
82  $customer->getFirstname() . ' ' . $customer->getLastname()
83  );
84  }
85  }
86  }
87 }
$customer
Definition: customers.php:11
__construct(Config $config, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, \Magento\Store\Model\StoreManagerInterface $storeManager, NewRelicWrapper $newRelicWrapper)