public function getOptimizedMetricsByDimensions(array $dimensions, StatsQueryInterface $query): array
    {
        $response = $this->getMetricsByDimensions($dimensions, $query, 'js');
        // If no analytics data returned for a given criteria just return.
        if (empty($response['stats'])) {
            return $response;
        }
        if (null !== $query->getTimeUnit()) {
            $originalTimeUnits = $response['TimeUnit'];
            $response['TimeUnit'] = $this->fillGapsInTimeUnitsData(
                $query->getTimeRange(),
                $query->getTimeUnit(),
                $query->getTsAscending()
            );
            foreach ($response['stats']['data'] as $key => $dimension) {
                $this->fillGapsInMetricsData(
                    $query->getTsAscending(),
                    $response['TimeUnit'],
                    $originalTimeUnits,
                    $response['stats']['data'][$key]['metric']
                );
            }
        }

        return $response;
    }
public function getOptimizedMetricsByDimensions(array $dimensions, StatsQueryInterface $query): array
    {
        $response = $this->getMetricsByDimensions($dimensions, $query, 'js');
        // If no analytics data returned for a given criteria just return.
        if (empty($response['stats'])) {
            return $response;
        }
        if (null !== $query->getTimeUnit()) {
            $originalTimeUnits = $response['TimeUnit'];
            $response['TimeUnit'] = $this->fillGapsInTimeUnitsData(
                $query->getTimeRange(),
                $query->getTimeUnit(),
                $query->getTsAscending()
            );
            foreach ($response['stats']['data'] as $key => $dimension) {
                $this->fillGapsInMetricsData(
                    $query->getTsAscending(),
                    $response['TimeUnit'],
                    $originalTimeUnits,
                    $response['stats']['data'][$key]['metric']
                );
            }
        }

        return $response;
    }
public function getOptimizedMetricsByDimensions ( array $ dimensions , StatsQueryInterface $ query ) : array { $ response = $ this -> getMetricsByDimensions ( $ dimensions , $ query , 'js' ) ; // If no analytics data returned for a given criteria just return. if ( empty ( $ response [ 'stats' ] ) ) { return $ response ; } if ( null !== $ query -> getTimeUnit ( ) ) { $ originalTimeUnits = $ response [ 'TimeUnit' ] ; $ response [ 'TimeUnit' ] = $ this -> fillGapsInTimeUnitsData ( $ query -> getTimeRange ( ) , $ query -> getTimeUnit ( ) , $ query -> getTsAscending ( ) ) ; foreach ( $ response [ 'stats' ] [ 'data' ] as $ key => $ dimension ) { $ this -> fillGapsInMetricsData ( $ query -> getTsAscending ( ) , $ response [ 'TimeUnit' ] , $ originalTimeUnits , $ response [ 'stats' ] [ 'data' ] [ $ key ] [ 'metric' ] ) ; } } return $ response ; }
Gets optimized metrics organized by dimensions.

The additional optimization on the returned data happens in the SDK. The SDK fills the gaps between time
units and analytics numbers in the returned response of Apigee Edge. If no analytics data returned for a
given criteria it does not fill in results with zeros, it just returns the original response.
(This method also asks optimized response from Apigee Edge too.)

@param array $dimensions
Array of dimensions.
@param StatsQueryInterface $query
Stats query object.

@throws \Moment\MomentException
@throws \InvalidArgumentException
Find more information in fillGapsInTimeUnitsData() method.

@return array
Response as associative array.

@psalm-suppress PossiblyNullArgument - $query->getTimeUnit() is not null.
Gets optimized metrics organized by dimensions .