From 434cf312e04c426e13a03a8992d009c11ded77f9 Mon Sep 17 00:00:00 2001 From: Ulhas Vardhan Golchha Date: Sun, 11 Jun 2023 13:02:57 +0530 Subject: [PATCH 1/3] Adds a $keepEmptyRows parameter to get the empty rows too. --- .gitignore | 1 + src/Analytics.php | 2 ++ src/AnalyticsClient.php | 2 ++ 3 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index b6285d6..ce12fd3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock docs vendor .phpunit.result.cache +/.idea/ diff --git a/src/Analytics.php b/src/Analytics.php index e0ce836..5ca970a 100644 --- a/src/Analytics.php +++ b/src/Analytics.php @@ -180,6 +180,7 @@ public function get( array $orderBy = [], int $offset = 0, FilterExpression $dimensionFilter = null, + bool $keepEmptyRows = false, ): Collection { return $this->client->get( $this->propertyId, @@ -190,6 +191,7 @@ public function get( $orderBy, $offset, $dimensionFilter, + $keepEmptyRows ); } } diff --git a/src/AnalyticsClient.php b/src/AnalyticsClient.php index 1e86e44..66f648c 100644 --- a/src/AnalyticsClient.php +++ b/src/AnalyticsClient.php @@ -36,6 +36,7 @@ public function get( array $orderBy = [], int $offset = 0, FilterExpression $dimensionFilter = null, + bool $keepEmptyRows = false, ): Collection { $typeCaster = resolve(TypeCaster::class); @@ -50,6 +51,7 @@ public function get( 'offset' => $offset, 'orderBys' => $orderBy, 'dimensionFilter' => $dimensionFilter, + 'keepEmptyRows' => $keepEmptyRows, ]); $result = collect(); From 851f27255bce0c63d2759a634e71bacb337cae83 Mon Sep 17 00:00:00 2001 From: Ulhas Vardhan Golchha Date: Fri, 16 Jun 2023 21:55:43 +0530 Subject: [PATCH 2/3] Updated the AnalyticsTest.php with $keepEmptyRows parameter value. --- tests/AnalyticsTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/AnalyticsTest.php b/tests/AnalyticsTest.php index 551958d..774d486 100644 --- a/tests/AnalyticsTest.php +++ b/tests/AnalyticsTest.php @@ -33,6 +33,7 @@ [], 0, null, + false, ]; $this @@ -72,6 +73,7 @@ ], 0, null, + false, ]; $this @@ -113,6 +115,7 @@ ], 0, null, + false, ]; $this @@ -155,6 +158,7 @@ ], 0, null, + false, ]; $this @@ -198,6 +202,7 @@ ], 0, null, + false, ]; $this @@ -237,6 +242,7 @@ ], 0, null, + false, ]; $this From 853212dcaab178c8ba044967efc917e9accc5b40 Mon Sep 17 00:00:00 2001 From: Ulhas Vardhan Golchha Date: Sat, 8 Jul 2023 12:49:02 +0530 Subject: [PATCH 3/3] Updated README.md with $keepEmptyRows parameter. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 734e8b9..fcf95e2 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,8 @@ Here's some extra info on the arguments you can pass: `array $offset`: Defaults to 0, you can use this in combination with the $limit param to have pagination. +`bool $keepEmptyRows`: If false or unspecified, each row with all metrics equal to 0 will not be returned. If true, these rows will be returned if they are not separately removed by a filter. + For example: ```php $orderBy = [