setSegment('bandwidth'); $segment->setType(Segment::TYPE_METRIC); $segment->setCategory('General_Actions'); $segment->setName('Bandwidth_Bandwidth'); $segment->setAcceptedValues('Any number in bytes, eg. 1000'); $segmentsList->addSegment($dimensionSegmentFactory->createSegment($segment)); } /** * This event is triggered before a new action is logged to the log_link_visit_action table. It overwrites any * looked up action so it makes usually no sense to implement both methods but it sometimes does. You can assign * any value to the column or return boolan false in case you do not want to save any value. * * @param Request $request * @param Visitor $visitor * @param Action $action * * @return mixed|false */ public function onNewAction(Request $request, Visitor $visitor, Action $action) { $value = Common::getRequestVar('bw_bytes', false, 'string', $request->getParams()); if (is_numeric($value)) { return (int)$value; } return false; } public function isUsedInSite($idSite, $period, $date, $columnToCompare) { if ($period === 'day' || $period === 'week') { $period = 'month'; } if (Range::isMultiplePeriod($date, $period)) { $period = 'range'; } $result = BandwidthApi::getInstance()->get($idSite, $period, $date); if (!$result->getRowsCount()) { return false; } $value = $result->getFirstRow()->getColumn($columnToCompare); return !empty($value); } }