protected function configureSegments()
{
$deviceTypes = DeviceParser::getAvailableDeviceTypeNames();
$deviceTypeList = implode(", ", $deviceTypes);
$segment = new Segment();
$segment->setCategory('General_Visit');
$segment->setSegment('deviceType');
$segment->setName('DevicesDetection_DeviceType');
$segment->setAcceptedValues($deviceTypeList);
$segment->setSqlFilter(function ($type) use($deviceTypeList, $deviceTypes) {
$index = array_search(strtolower(trim(urldecode($type))), $deviceTypes);
if ($index === false) {
throw new Exception("deviceType segment must be one of: {$deviceTypeList}");
}
return $index;
});
$this->addSegment($segment);
}