diff --git a/src/Facades/LaravelGoogleAnalytics.php b/src/Facades/LaravelGoogleAnalytics.php index c51234e..31e1d29 100644 --- a/src/Facades/LaravelGoogleAnalytics.php +++ b/src/Facades/LaravelGoogleAnalytics.php @@ -25,6 +25,7 @@ * @method static self metricAggregations(int ...$items) * @method static self whereDimension(string $name, int $matchType, $value, bool $caseSensitive = false) * @method static self whereDimensionIn(string $name, array $values, bool $caseSensitive = false) + * @method static self whereAndGroupDimensions(array $dimensions) * @method static self whereMetric(string $name, int $operation, $value) * @method static self whereMetricBetween(string $name, $from, $to) * @method static \Google\Analytics\Data\V1beta\NumericValue getNumericObject( $value) diff --git a/src/Traits/FilterByDimensionTrait.php b/src/Traits/FilterByDimensionTrait.php index 3320c85..0c4f1ea 100644 --- a/src/Traits/FilterByDimensionTrait.php +++ b/src/Traits/FilterByDimensionTrait.php @@ -105,13 +105,21 @@ protected function createDimensionGroup($dimensions): array $filterExpressionList = []; foreach ($dimensions as $dimension) { - $stringFilter = (new StringFilter())->setCaseSensitive($dimension[3] ?? false) - ->setMatchType($dimension[1]) - ->setValue($dimension[2]); + if($dimension instanceof Filter){ + $filterExpressionList[] = (new FilterExpression())->setFilter($dimension); + continue; + } - $filter = (new Filter())->setStringFilter($stringFilter)->setFieldName($dimension[0]); + if(is_array($dimension)){ + $stringFilter = (new StringFilter())->setCaseSensitive($dimension[3] ?? false) + ->setMatchType($dimension[1]) + ->setValue($dimension[2]); - $filterExpressionList[] = (new FilterExpression())->setFilter($filter); + $filter = (new Filter())->setStringFilter($stringFilter)->setFieldName($dimension[0]); + $filterExpressionList[] = (new FilterExpression())->setFilter($filter); + } + + // TODO: Throw and invalid dimension exception? } return $filterExpressionList;