Example #1
0
 public function testAddGetDimension()
 {
     $le = new LogEntry('page');
     $this->assertSame([], $le->getDimensions());
     $le->addDimension('browser', 'fireWolf', 100);
     /**
      * @var $dim LogDimension
      */
     $dim = $le->getDimensions()[0];
     $this->assertInstanceOf('Webiny\\AnalyticsDb\\LogDimension', $dim);
     $this->assertSame('browser', $dim->getName());
     $this->assertSame('fireWolf', $dim->getValue());
     $this->assertSame(100, $dim->getIncrement());
 }
Example #2
0
 /**
  * Add a log to the buffer.
  * Note: the data is not saved until you call the save method.
  *
  * @param string $entity Entity name.
  * @param int    $ref
  * @param int    $increment
  *
  * @return LogEntry
  * @throws AnalyticsDbException
  */
 public function log($entity, $ref = 0, $increment = 1)
 {
     if (!preg_match('/^([A-z0-9\\/\\-\\_]+)$/', $entity)) {
         throw new AnalyticsDbException('Entity name can only contain ([A-z0-9\\/\\-]).');
     }
     if (!preg_match('/^([A-z0-9\\/\\-\\_]+)$/', $ref)) {
         throw new AnalyticsDbException('Entity referrer can only contain ([A-z0-9\\/\\-]).');
     }
     $entry = new LogEntry($entity);
     $entry->setRef($ref);
     $entry->setIncrement($increment);
     $this->logBuffer->addEntry($entry);
     return $entry;
 }