/**
  * 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());
         }
     }
 }
 /**
  * Reports any products created or updated to New Relic
  *
  * @param Observer $observer
  * @return void
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNewRelicEnabled()) {
         /** @var \Magento\Catalog\Model\Product $product */
         $product = $observer->getEvent()->getProduct();
         if ($product->isObjectNew()) {
             $this->newRelicWrapper->addCustomParameter(\Magento\NewRelicReporting\Model\Config::PRODUCT_CHANGE, 'create');
         } else {
             $this->newRelicWrapper->addCustomParameter(\Magento\NewRelicReporting\Model\Config::PRODUCT_CHANGE, 'update');
         }
     }
 }
 /**
  * Adds New Relic custom parameters per request for store, website, and logged in user if applicable
  *
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNewRelicEnabled()) {
         $this->newRelicWrapper->addCustomParameter(Config::STORE, $this->storeManager->getStore()->getName());
         $this->newRelicWrapper->addCustomParameter(Config::WEBSITE, $this->storeManager->getWebsite()->getName());
         if ($this->customerSession->isLoggedIn()) {
             $customer = $this->customerRepository->getById($this->customerSession->getCustomerId());
             $this->newRelicWrapper->addCustomParameter(Config::CUSTOMER_ID, $customer->getId());
             $this->newRelicWrapper->addCustomParameter(Config::CUSTOMER_NAME, $customer->getFirstname() . ' ' . $customer->getLastname());
         }
     }
 }
 /**
  * Reports orders placed to New Relic
  *
  * @param Observer $observer
  * @return void
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNewRelicEnabled()) {
         /** @var \Magento\Sales\Model\Order $order */
         $order = $observer->getEvent()->getOrder();
         $itemCount = $order->getTotalItemCount();
         if (!is_numeric($itemCount) && empty($itemCount)) {
             $itemCount = $order->getTotalQtyOrdered();
         }
         $this->newRelicWrapper->addCustomParameter(Config::ORDER_PLACED, 1);
         $this->newRelicWrapper->addCustomParameter(Config::ORDER_ITEMS, $itemCount);
         $this->newRelicWrapper->addCustomParameter(Config::ORDER_VALUE, $order->getBaseGrandTotal());
     }
 }
 /**
  * Reports any products deleted to New Relic
  *
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(Observer $observer)
 {
     if ($this->config->isNewRelicEnabled()) {
         $this->newRelicWrapper->addCustomParameter(Config::PRODUCT_CHANGE, 'delete');
     }
 }