Skip to content

Commit

Permalink
Fixes breaking changes in laravel analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
lewiswharf authored and ifox committed Jan 26, 2024
1 parent cfbeaf5 commit 6309324
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Http/Controllers/Admin/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,26 +288,26 @@ private function formatAuthActivity(Activity $activity): array
private function getFacts()
{
/** @var Analytics $analytics */
$analytics = app(Analytics::class);
$analytics = app()->makeWith(Analytics::class, ['propertyId' => config('analytics.property_id')]);
try {
$response = $analytics->performQuery(
$response = $analytics->get(
Period::days(60),
'ga:users,ga:pageviews,ga:bouncerate,ga:pageviewsPerSession',
['dimensions' => 'ga:date']
['totalUsers', 'screenPageViews', 'bounceRate', 'screenPageViewsPerSession'],
['date']
);
} catch (InvalidConfiguration $exception) {
$this->logger->error($exception);

return [];
}

$statsByDate = Collection::make($response['rows'] ?? [])->map(function (array $dateRow) {
$statsByDate = $response->map(function (array $item) {
return [
'date' => $dateRow[0],
'users' => (int) $dateRow[1],
'pageViews' => (int) $dateRow[2],
'bounceRate' => $dateRow[3],
'pageviewsPerSession' => $dateRow[4],
'date' => $item['date'],
'users' => (int) $item['totalUsers'],
'pageViews' => (int) $item['screenPageViews'],
'bounceRate' => $item['bounceRate'],
'pageviewsPerSession' => $item['screenPageViewsPerSession'],
];
})->reverse()->values();

Expand Down

0 comments on commit 6309324

Please sign in to comment.