* Remove Google Analytics #728 * Remove config file * Don't set the vacentral url
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
use App\Contracts\Enum;
|
||||
|
||||
class AnalyticsDimensions extends Enum
|
||||
{
|
||||
public const PHP_VERSION = 1;
|
||||
public const DATABASE_VERSION = 2;
|
||||
public const PHPVMS_VERSION = 3;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
use App\Contracts\Enum;
|
||||
|
||||
/**
|
||||
* Metrics IDs used in Google Analytics
|
||||
*/
|
||||
class AnalyticsMetrics extends Enum
|
||||
{
|
||||
// Track the lookup time for airports from vaCentral
|
||||
public const AIRPORT_LOOKUP_TIME = 1;
|
||||
}
|
||||
@@ -32,7 +32,6 @@ class BindServiceProviders extends ServiceProvider
|
||||
IVaCentral::class,
|
||||
function ($app) {
|
||||
$client = new VaCentral();
|
||||
$client->setVaCentralUrl(config('vacentral.api_url'));
|
||||
|
||||
// Set API if exists
|
||||
if (filled(config('vacentral.api_key'))) {
|
||||
|
||||
@@ -21,13 +21,14 @@ class VaCentralLookup extends AirportLookup
|
||||
*
|
||||
* @param string $icao
|
||||
*
|
||||
* @return array
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAirport($icao)
|
||||
{
|
||||
try {
|
||||
$airport = $this->client->getAirport($icao);
|
||||
$airport->location = $airport->city;
|
||||
|
||||
return $airport;
|
||||
} catch (HttpException $e) {
|
||||
Log::error($e);
|
||||
|
||||
@@ -3,25 +3,15 @@
|
||||
namespace App\Services;
|
||||
|
||||
use App\Contracts\Service;
|
||||
use App\Models\Enums\AnalyticsDimensions;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Irazasyed\LaravelGAMP\Facades\GAMP;
|
||||
use PDO;
|
||||
use VaCentral\Models\Stat;
|
||||
use VaCentral\VaCentral;
|
||||
|
||||
class AnalyticsService extends Service
|
||||
{
|
||||
/**
|
||||
* Create a GAMP instance with a random ID
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getGAMPInstance()
|
||||
{
|
||||
return GAMP::setClientId(uniqid('', true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out some stats about the install, like the PHP and DB versions
|
||||
*/
|
||||
@@ -31,31 +21,39 @@ class AnalyticsService extends Service
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a random client ID
|
||||
$gamp = $this->getGAMPInstance();
|
||||
|
||||
$gamp->setDocumentPath('/install');
|
||||
|
||||
// Send the PHP version
|
||||
$gamp->setCustomDimension(PHP_VERSION, AnalyticsDimensions::PHPVMS_VERSION);
|
||||
|
||||
// Figure out the database version
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$gamp->setCustomDimension(
|
||||
strtolower($pdo->getAttribute(PDO::ATTR_SERVER_VERSION)),
|
||||
AnalyticsDimensions::DATABASE_VERSION
|
||||
);
|
||||
|
||||
// Send the PHPVMS Version
|
||||
$versionSvc = app(VersionService::class);
|
||||
$gamp->setCustomDimension(
|
||||
$versionSvc->getCurrentVersion(false),
|
||||
AnalyticsDimensions::PHP_VERSION
|
||||
);
|
||||
$pdo = DB::connection()->getPdo();
|
||||
|
||||
$props = [
|
||||
'php' => PHP_VERSION,
|
||||
'db' => strtolower($pdo->getAttribute(PDO::ATTR_SERVER_VERSION)),
|
||||
'version' => $versionSvc->getCurrentVersion(false),
|
||||
];
|
||||
|
||||
// Send that an install was done
|
||||
try {
|
||||
$gamp->sendPageview();
|
||||
$stat = Stat::new('event', 'install', $props);
|
||||
$client = new VaCentral();
|
||||
$client->postStat($stat);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function sendUpdate()
|
||||
{
|
||||
if (setting('general.telemetry') === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$versionSvc = app(VersionService::class);
|
||||
$props = [
|
||||
'version' => $versionSvc->getCurrentVersion(false),
|
||||
];
|
||||
|
||||
try {
|
||||
$stat = Stat::new('event', 'update', $props);
|
||||
$client = new VaCentral();
|
||||
$client->postStat($stat);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user