/**
  * Log a visitor.
  *
  * @param array $statHandlers List of stat handlers that will be added to the analytics db as a dimension.
  *
  * @throws \Webiny\AnalyticsDb\AnalyticsDbException
  */
 private function logVisitor($statHandlers)
 {
     $log = $this->analyticsDb->log(self::STAT_VISITOR);
     foreach ($statHandlers as $k => $v) {
         $log->addDimension($k, $v);
     }
 }
Esempio n. 2
0
 public function testLog()
 {
     $this->assertInstanceOf('Webiny\\AnalyticsDb\\LogBuffer', $this->instance->getLogBuffer());
     $this->assertSame([], $this->instance->getLogBuffer()->getEntries());
     $this->instance->log('browser', 100, 10);
     $this->assertSame(1, count($this->instance->getLogBuffer()->getEntries()));
     $this->instance->log('browser', 101);
     $this->assertSame(2, count($this->instance->getLogBuffer()->getEntries()));
     $log = $this->instance->getLogBuffer()->getEntries()[0];
     $this->assertInstanceOf('Webiny\\AnalyticsDb\\LogEntry', $log);
     $this->assertSame('browser', $log->getName());
     $this->assertSame(100, $log->getRef());
     $this->assertSame(10, $log->getIncrement());
     $this->instance->save();
     $this->assertSame([], $this->instance->getLogBuffer()->getEntries());
 }