/** * Create metrics about the order creation * * @param OrderOnCreatedEvent $event Event */ public function addMetric(OrderOnCreatedEvent $event) { $storeTracker = $this->store->getTracker(); $this->metricManager->addEntry($storeTracker, 'order_nb', '0', ElcodiMetricTypes::TYPE_BEACON_ALL, new DateTime()); $orderAmount = $event->getOrder()->getAmount()->getAmount(); $this->metricManager->addEntry($storeTracker, 'order_total', $orderAmount, ElcodiMetricTypes::TYPE_ACCUMULATED, new DateTime()); }
/** * /token/event.pixel * * @param string $token Event * @param string $event Token * * @return Response Empty response */ public function addEntryAction($token, $event) { $requestQuery = $this->requestStack->getCurrentRequest()->query; $value = $requestQuery->get('i', 0); $type = (int) $requestQuery->get('t', ElcodiMetricTypes::TYPE_BEACON_ALL); $this->metricManager->addEntry($token, $event, $value, $type, $this->dateTimeFactory->create()); $content = base64_decode(self::IMAGE_CONTENT); $response = new Response($content); $response->setPrivate(); $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->set('Content-Type', 'image/png'); return $response; }