public function determineCategory($userAgent = null, $defaultGrade = Grades::UNSUPPORTED) {
        $logger = $GLOBALS['logger'];
        $app = $GLOBALS['app'];
        $parsedUA = UA::parse($userAgent);
        if (!empty($app) && !$app->getConfiguration()->isLocal()) {
            try {
                $logger->info('Attempting device lookup in database');
                $browser = $this->_lookupDB($parsedUA);
                return $this->_computeCategory($browser);
            } catch (\Exception $ex) {
                $logger->info("No device database found, defaulting to local file based detection");
                $browser = $this->_lookupLocal($parsedUA, $defaultGrade);
                return $this->_computeCategory($browser);
            }
        } else {
            //$logger->info("Local environment, defaulting to local file based detection");
            $browser = $this->_lookupLocal($parsedUA, $defaultGrade);
            return $this->_computeCategory($browser);
        }
    }