Skip to content

Commit

Permalink
Allow "Google_Service_Analytics_GaData" return type for performQuery …
Browse files Browse the repository at this point in the history
…methods (#402)

* Allow Google_Service_Analytics_GaData return type  for performQuery methods

* Update docblocks
  • Loading branch information
oostation authored Jun 10, 2021
1 parent 113ae4b commit 0659015
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Carbon\Carbon;
use Google_Service_Analytics;
use Google_Service_Analytics_GaData;
use Illuminate\Support\Collection;
use Illuminate\Support\Traits\Macroable;

Expand Down Expand Up @@ -153,9 +154,9 @@ protected function summarizeTopBrowsers(Collection $topBrowsers, int $maxResults
* @param string $metrics
* @param array $others
*
* @return array|null
* @return Google_Service_Analytics_GaData|array|null
*/
public function performQuery(Period $period, string $metrics, array $others = []): array | null
public function performQuery(Period $period, string $metrics, array $others = []): Google_Service_Analytics_GaData | array | null
{
return $this->client->performQuery(
$this->viewId,
Expand Down
5 changes: 3 additions & 2 deletions src/AnalyticsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DateTimeInterface;
use Google_Service_Analytics;
use Google_Service_Analytics_GaData;
use Illuminate\Contracts\Cache\Repository;

class AnalyticsClient
Expand Down Expand Up @@ -33,9 +34,9 @@ public function setCacheLifeTimeInMinutes(int $cacheLifeTimeInMinutes): self
* @param string $metrics
* @param array $others
*
* @return array|null
* @return Google_Service_Analytics_GaData|array|null
*/
public function performQuery(string $viewId, DateTimeInterface $startDate, DateTimeInterface $endDate, string $metrics, array $others = []): array | null
public function performQuery(string $viewId, DateTimeInterface $startDate, DateTimeInterface $endDate, string $metrics, array $others = []): Google_Service_Analytics_GaData | array | null
{
$cacheName = $this->determineCacheName(func_get_args());

Expand Down

1 comment on commit 0659015

@debashishjena
Copy link

@debashishjena debashishjena commented on 0659015 Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Can you help me.
Google analytics working fine my localhost Laravel 9 but given error in server

web[enter image description here](https://i.stack.imgur.com/TPyhe.png).php Class "Analytics" not found
server php v 8+
laravel 9
Analytics latest 4.1

Error Class "Analytics" not found
working fine in localhost , all data return. when deployed in server giving error.
also run successfully composer dump-autoload and server vendor/ composer two files replace autoload_classmap.php / autoload_static.php
also lower version download 3.11 and same issues coming.

web.php included
use Spatie\Analytics\Period;

Route::get('/ganalytics', function () 
{
    $analyticsData = Analytics::fetchVisitorsAndPageViews(Period::days(7));
    return view('ganalytics.G4A', ['analyticsData' => $analyticsData]);
})->name('ganalytics.G4A');

why server given error Google analytics working fine my localhost Laravel 9

Please sign in to comment.