Skip to content

Commit

Permalink
Merge pull request #494 from golchha21/main
Browse files Browse the repository at this point in the history
Adds a $keepEmptyRows parameter to get the empty rows too.
  • Loading branch information
timvandijck authored Jul 10, 2023
2 parents 129ad8b + 853212d commit 778724f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
docs
vendor
.phpunit.result.cache
/.idea/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 2 additions & 0 deletions src/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -190,6 +191,7 @@ public function get(
$orderBy,
$offset,
$dimensionFilter,
$keepEmptyRows
);
}
}
2 changes: 2 additions & 0 deletions src/AnalyticsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function get(
array $orderBy = [],
int $offset = 0,
FilterExpression $dimensionFilter = null,
bool $keepEmptyRows = false,
): Collection {
$typeCaster = resolve(TypeCaster::class);

Expand All @@ -50,6 +51,7 @@ public function get(
'offset' => $offset,
'orderBys' => $orderBy,
'dimensionFilter' => $dimensionFilter,
'keepEmptyRows' => $keepEmptyRows,
]);

$result = collect();
Expand Down
6 changes: 6 additions & 0 deletions tests/AnalyticsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
[],
0,
null,
false,
];

$this
Expand Down Expand Up @@ -72,6 +73,7 @@
],
0,
null,
false,
];

$this
Expand Down Expand Up @@ -113,6 +115,7 @@
],
0,
null,
false,
];

$this
Expand Down Expand Up @@ -155,6 +158,7 @@
],
0,
null,
false,
];

$this
Expand Down Expand Up @@ -198,6 +202,7 @@
],
0,
null,
false,
];

$this
Expand Down Expand Up @@ -237,6 +242,7 @@
],
0,
null,
false,
];

$this
Expand Down

0 comments on commit 778724f

Please sign in to comment.