diff --git a/CHANGELOG.md b/CHANGELOG.md index cd3741e..0cdd293 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All Notable changes to `laravel-search-console` will be documented in this file. +## [1.7.1] - 2021-04-11 +- Add 'AggregationType' request and response parameter + ## [1.7.0] - 2021-04-11 - Add 'dataState' request and response parameter diff --git a/README.md b/README.md index a45e594..eebdb6f 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,8 @@ $sites = SearchConsole::setAccessToken($token)->listSites(); [['dimension' => 'query', 'operator' => 'notContains', 'expression' => 'cheesecake']], 1000, 'web', - 'all' + 'all', + 'auto' ); ``` @@ -130,7 +131,7 @@ public function public function listSites(): Collection ### Retrieve Search Analytics Data ```php -public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final'): Collection +public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final', string $aggregationType = 'auto'): Collection ``` ### Check Access Token diff --git a/src/ExponentialBackoff.php b/src/ExponentialBackoff.php index 3612956..3d286eb 100644 --- a/src/ExponentialBackoff.php +++ b/src/ExponentialBackoff.php @@ -61,7 +61,7 @@ public function execute(callable $function, array $arguments = []) } } - if ($exception->getCode() == 401 || $exception->getCode() == 403) { + if ($exception->getCode() >= 400 && $exception->getCode() <= 499) { break; } diff --git a/src/SearchConsole.php b/src/SearchConsole.php index c1b2b86..2481a49 100644 --- a/src/SearchConsole.php +++ b/src/SearchConsole.php @@ -95,10 +95,11 @@ public function listSites() * @param int $rows * @param string $searchType * @param string $dataState + * @param string $aggregationType * @return Collection * @throws \Exception */ - public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final') + public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final', string $aggregationType = 'auto') { $request = new Google_Service_Webmasters_SearchAnalyticsQueryRequest(); $request->setStartDate($period->startDate->toDateString()); @@ -106,6 +107,7 @@ public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dim $request->setSearchType($searchType); $request->setDimensions($dimensions); $request->setDataState($dataState); + $request->setAggregationType($aggregationType); $request = $this->applyFilters($request, $filters); return $this->client->performQuery($siteUrl, $rows, $request); diff --git a/src/SearchConsoleClient.php b/src/SearchConsoleClient.php index 50d4543..c3e5029 100644 --- a/src/SearchConsoleClient.php +++ b/src/SearchConsoleClient.php @@ -82,6 +82,7 @@ public function performQuery($siteUrl, $rows, $request): Collection $item['position'] = $row->getPosition(); $item['searchType'] = $request->getSearchType(); $item['dataState'] = $request->getDataState(); + $item['aggregationType'] = $request->getAggregationType(); $dataRows->put($uniqueHash, $item); }