Piwik\API\Inconsistencies::getPercentMetricsToFormat PHP Метод

getPercentMetricsToFormat() публичный Метод

This method returns the list of percent metrics that were returned from the API formatted so we can maintain BC. Used by DataTablePostProcessor.
    public function getPercentMetricsToFormat()
    {
        return array('bounce_rate', 'conversion_rate', 'abandoned_rate', 'interaction_rate', 'exit_rate', 'bounce_rate_returning', 'nb_visits_percentage', '/.*_evolution/', '/goal_.*_conversion_rate/');
    }

Usage Example

Пример #1
0
 /**
  * @param DataTableInterface $dataTable
  * @return DataTableInterface
  */
 public function applyMetricsFormatting($dataTable)
 {
     $formatMetrics = Common::getRequestVar('format_metrics', 0, 'string', $this->request);
     if ($formatMetrics == '0') {
         return $dataTable;
     }
     // in Piwik 2.X & below, metrics are not formatted in API responses except for percents.
     // this code implements this inconsistency
     $onlyFormatPercents = $formatMetrics === 'bc';
     $metricsToFormat = null;
     if ($onlyFormatPercents) {
         $metricsToFormat = $this->apiInconsistencies->getPercentMetricsToFormat();
     }
     $dataTable->filter(array($this->formatter, 'formatMetrics'), array($this->report, $metricsToFormat));
     return $dataTable;
 }