Skip to content

Commit

Permalink
Add offset params to all methods that accept a limit.
Browse files Browse the repository at this point in the history
  • Loading branch information
timvandijck committed May 17, 2023
1 parent e45c330 commit c95f646
Showing 1 changed file with 41 additions and 35 deletions.
76 changes: 41 additions & 35 deletions src/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ public function getPropertyId(): string
* screenPageViews: int
* }>
*/
public function fetchVisitorsAndPageViews(Period $period, int $maxResults = 10): Collection
public function fetchVisitorsAndPageViews(Period $period, int $maxResults = 10, int $offset = 0): Collection
{
return $this->get(
$period,
['activeUsers', 'screenPageViews'],
['pageTitle'],
$maxResults,
period: $period,
metrics: ['activeUsers', 'screenPageViews'],
dimensions: ['pageTitle'],
maxResults: $maxResults,
offset: $offset,
);
}

Expand All @@ -54,16 +55,17 @@ public function fetchVisitorsAndPageViews(Period $period, int $maxResults = 10):
* screenPageViews: int
* }>
*/
public function fetchVisitorsAndPageViewsByDate(Period $period, int $maxResults = 10): Collection
public function fetchVisitorsAndPageViewsByDate(Period $period, int $maxResults = 10, $offset = 0): Collection
{
return $this->get(
$period,
['activeUsers', 'screenPageViews'],
['pageTitle', 'date'],
$maxResults,
[
period: $period,
metrics: ['activeUsers', 'screenPageViews'],
dimensions: ['pageTitle', 'date'],
maxResults: $maxResults,
orderBy: [
OrderBy::dimension('date', true),
],
offset: $offset,
);
}

Expand All @@ -75,16 +77,17 @@ public function fetchVisitorsAndPageViewsByDate(Period $period, int $maxResults
* screenPageViews: int
* }>
*/
public function fetchTotalVisitorsAndPageViews(Period $period, int $maxResults = 20): Collection
public function fetchTotalVisitorsAndPageViews(Period $period, int $maxResults = 20, int $offset = 0): Collection
{
return $this->get(
$period,
['activeUsers', 'screenPageViews'],
['date'],
$maxResults,
[
period: $period,
metrics: ['activeUsers', 'screenPageViews'],
dimensions: ['date'],
maxResults: $maxResults,
orderBy: [
OrderBy::dimension('date', true),
],
offset: $offset,
);
}

Expand All @@ -96,16 +99,17 @@ public function fetchTotalVisitorsAndPageViews(Period $period, int $maxResults =
* screenPageViews: int
* }>
*/
public function fetchMostVisitedPages(Period $period, int $maxResults = 20): Collection
public function fetchMostVisitedPages(Period $period, int $maxResults = 20, int $offset = 0): Collection
{
return $this->get(
$period,
['screenPageViews'],
['pageTitle', 'fullPageUrl'],
$maxResults,
[
period: $period,
metrics: ['screenPageViews'],
dimensions: ['pageTitle', 'fullPageUrl'],
maxResults: $maxResults,
orderBy: [
OrderBy::metric('screenPageViews', true),
],
offset: $offset,
);
}

Expand All @@ -116,16 +120,17 @@ public function fetchMostVisitedPages(Period $period, int $maxResults = 20): Col
* screenPageViews: int
* }>
*/
public function fetchTopReferrers(Period $period, int $maxResults = 20): Collection
public function fetchTopReferrers(Period $period, int $maxResults = 20, int $offset = 0): Collection
{
return $this->get(
$period,
['screenPageViews'],
['pageReferrer'],
$maxResults,
[
period: $period,
metrics: ['screenPageViews'],
dimensions: ['pageReferrer'],
maxResults: $maxResults,
orderBy: [
OrderBy::metric('screenPageViews', true),
],
offset: $offset,
);
}

Expand All @@ -152,16 +157,17 @@ public function fetchUserTypes(Period $period): Collection
* screenPageViews: int
* }>
*/
public function fetchTopBrowsers(Period $period, int $maxResults = 10): Collection
public function fetchTopBrowsers(Period $period, int $maxResults = 10, int $offset = 0): Collection
{
return $this->get(
$period,
['screenPageViews'],
['browser'],
$maxResults,
[
period: $period,
metrics: ['screenPageViews'],
dimensions: ['browser'],
maxResults: $maxResults,
orderBy: [
OrderBy::metric('screenPageViews', true),
],
offset: $offset,
);
}

Expand Down

0 comments on commit c95f646

Please sign in to comment.