From aaae12e6910e84c13c08fa54ba29e6324ea28d10 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 19 May 2024 19:42:20 +1000 Subject: [PATCH] Capture additional metrics --- app/DataMapper/Analytics/DbQuery.php | 4 ++++ app/Http/Middleware/QueryLogging.php | 17 ++++++++++++++++- database/factories/AccountFactory.php | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/DataMapper/Analytics/DbQuery.php b/app/DataMapper/Analytics/DbQuery.php index c5718278dab0..ac65c29b36c0 100644 --- a/app/DataMapper/Analytics/DbQuery.php +++ b/app/DataMapper/Analytics/DbQuery.php @@ -52,6 +52,10 @@ class DbQuery extends GenericMixedMetric public $string_metric7 = 'ip_address'; + public $string_metric8 = 'client_version'; + + public $string_metric9 = 'platform'; + /** * The counter * set to 1. diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 106d498cb55f..8f1b8b546e5b 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -73,7 +73,22 @@ class QueryLogging $ip = $request->ip(); } - LightLogs::create(new DbQuery($request->method(), substr(urldecode($request->url()), 0, 180), $count, $time, $ip)) + $client_version = ''; + $platform = ''; + + if ($request->hasHeader('X-CLIENT-PLATFORM')) { + $platform = $request->header('X-CLIENT-PLATFORM'); + } + elseif($request->hasHeader('X-React')){ + $platform = 'react'; + } + + if ($request->hasHeader('X-CLIENT-VERSION')) + { + $client_version = $request->header('X-CLIENT-VERSION'); + } + + LightLogs::create(new DbQuery($request->method(), substr(urldecode($request->url()), 0, 180), $count, $time, $ip, $client_version, $platform)) ->batch(); } diff --git a/database/factories/AccountFactory.php b/database/factories/AccountFactory.php index 371c2a3f9193..17cb13d7e89e 100644 --- a/database/factories/AccountFactory.php +++ b/database/factories/AccountFactory.php @@ -27,6 +27,7 @@ class AccountFactory extends Factory 'default_company_id' => 1, 'key' => Str::random(32), 'report_errors' => 1, + 'referral_code' => Str::lower(Str::random(32)), ]; } }