From 6309324a4416d4bd4b1b9285b131d32605caef28 Mon Sep 17 00:00:00 2001 From: Mark Lewis Date: Sat, 10 Jun 2023 14:14:41 -0400 Subject: [PATCH] Fixes breaking changes in laravel analytics --- .../Controllers/Admin/DashboardController.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Http/Controllers/Admin/DashboardController.php b/src/Http/Controllers/Admin/DashboardController.php index 702d1b2d7..ba32a92fc 100644 --- a/src/Http/Controllers/Admin/DashboardController.php +++ b/src/Http/Controllers/Admin/DashboardController.php @@ -288,12 +288,12 @@ 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); @@ -301,13 +301,13 @@ private function getFacts() 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();