* Remove Google Analytics #728 * Remove config file * Don't set the vacentral url
This commit is contained in:
parent
c1408cb8fe
commit
3d211535f7
@ -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,
|
IVaCentral::class,
|
||||||
function ($app) {
|
function ($app) {
|
||||||
$client = new VaCentral();
|
$client = new VaCentral();
|
||||||
$client->setVaCentralUrl(config('vacentral.api_url'));
|
|
||||||
|
|
||||||
// Set API if exists
|
// Set API if exists
|
||||||
if (filled(config('vacentral.api_key'))) {
|
if (filled(config('vacentral.api_key'))) {
|
||||||
|
@ -21,13 +21,14 @@ class VaCentralLookup extends AirportLookup
|
|||||||
*
|
*
|
||||||
* @param string $icao
|
* @param string $icao
|
||||||
*
|
*
|
||||||
* @return array
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getAirport($icao)
|
public function getAirport($icao)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$airport = $this->client->getAirport($icao);
|
$airport = $this->client->getAirport($icao);
|
||||||
$airport->location = $airport->city;
|
$airport->location = $airport->city;
|
||||||
|
|
||||||
return $airport;
|
return $airport;
|
||||||
} catch (HttpException $e) {
|
} catch (HttpException $e) {
|
||||||
Log::error($e);
|
Log::error($e);
|
||||||
|
@ -3,25 +3,15 @@
|
|||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Contracts\Service;
|
use App\Contracts\Service;
|
||||||
use App\Models\Enums\AnalyticsDimensions;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Irazasyed\LaravelGAMP\Facades\GAMP;
|
|
||||||
use PDO;
|
use PDO;
|
||||||
|
use VaCentral\Models\Stat;
|
||||||
|
use VaCentral\VaCentral;
|
||||||
|
|
||||||
class AnalyticsService extends Service
|
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
|
* Send out some stats about the install, like the PHP and DB versions
|
||||||
*/
|
*/
|
||||||
@ -31,31 +21,39 @@ class AnalyticsService extends Service
|
|||||||
return;
|
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);
|
$versionSvc = app(VersionService::class);
|
||||||
$gamp->setCustomDimension(
|
$pdo = DB::connection()->getPdo();
|
||||||
$versionSvc->getCurrentVersion(false),
|
|
||||||
AnalyticsDimensions::PHP_VERSION
|
$props = [
|
||||||
);
|
'php' => PHP_VERSION,
|
||||||
|
'db' => strtolower($pdo->getAttribute(PDO::ATTR_SERVER_VERSION)),
|
||||||
|
'version' => $versionSvc->getCurrentVersion(false),
|
||||||
|
];
|
||||||
|
|
||||||
// Send that an install was done
|
|
||||||
try {
|
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) {
|
} catch (Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@
|
|||||||
"spatie/laravel-backup": "~6.9.0",
|
"spatie/laravel-backup": "~6.9.0",
|
||||||
"spatie/valuestore": "~1.2.3",
|
"spatie/valuestore": "~1.2.3",
|
||||||
"symfony/polyfill-iconv": "~1.17.0",
|
"symfony/polyfill-iconv": "~1.17.0",
|
||||||
"theiconic/php-ga-measurement-protocol": "2.7.*",
|
|
||||||
"tivie/php-os-detector": "~1.1.0",
|
"tivie/php-os-detector": "~1.1.0",
|
||||||
"vlucas/phpdotenv": "v4.0",
|
"vlucas/phpdotenv": "v4.0",
|
||||||
"webpatser/laravel-uuid": "~3.0",
|
"webpatser/laravel-uuid": "~3.0",
|
||||||
|
1299
composer.lock
generated
1299
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'tracking_id' => 'UA-100567975-4',
|
|
||||||
'protocol_version' => 1,
|
|
||||||
'is_ssl' => true,
|
|
||||||
'is_disabled' => false,
|
|
||||||
'anonymize_ip' => true,
|
|
||||||
'async_requests' => true,
|
|
||||||
];
|
|
@ -4,6 +4,7 @@ namespace Modules\Updater\Http\Controllers;
|
|||||||
|
|
||||||
use App\Contracts\Controller;
|
use App\Contracts\Controller;
|
||||||
use App\Repositories\KvpRepository;
|
use App\Repositories\KvpRepository;
|
||||||
|
use App\Services\AnalyticsService;
|
||||||
use App\Services\Installer\InstallerService;
|
use App\Services\Installer\InstallerService;
|
||||||
use App\Services\Installer\MigrationService;
|
use App\Services\Installer\MigrationService;
|
||||||
use App\Services\Installer\SeederService;
|
use App\Services\Installer\SeederService;
|
||||||
@ -14,6 +15,7 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
class UpdateController extends Controller
|
class UpdateController extends Controller
|
||||||
{
|
{
|
||||||
|
private $analyticsSvc;
|
||||||
private $installerSvc;
|
private $installerSvc;
|
||||||
private $kvpRepo;
|
private $kvpRepo;
|
||||||
private $migrationSvc;
|
private $migrationSvc;
|
||||||
@ -21,19 +23,22 @@ class UpdateController extends Controller
|
|||||||
private $updateManager;
|
private $updateManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param AnalyticsService $analyticsSvc
|
||||||
* @param InstallerService $installerSvc
|
* @param InstallerService $installerSvc
|
||||||
|
* @param KvpRepository $kvpRepo
|
||||||
* @param MigrationService $migrationSvc
|
* @param MigrationService $migrationSvc
|
||||||
* @param SeederService $seederSvc
|
* @param SeederService $seederSvc
|
||||||
* @param KvpRepository $kvpRepo
|
|
||||||
* @param UpdaterManager $updateManager
|
* @param UpdaterManager $updateManager
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
AnalyticsService $analyticsSvc,
|
||||||
InstallerService $installerSvc,
|
InstallerService $installerSvc,
|
||||||
KvpRepository $kvpRepo,
|
KvpRepository $kvpRepo,
|
||||||
MigrationService $migrationSvc,
|
MigrationService $migrationSvc,
|
||||||
SeederService $seederSvc,
|
SeederService $seederSvc,
|
||||||
UpdaterManager $updateManager
|
UpdaterManager $updateManager
|
||||||
) {
|
) {
|
||||||
|
$this->analyticsSvc = $analyticsSvc;
|
||||||
$this->migrationSvc = $migrationSvc;
|
$this->migrationSvc = $migrationSvc;
|
||||||
$this->seederSvc = $seederSvc;
|
$this->seederSvc = $seederSvc;
|
||||||
$this->installerSvc = $installerSvc;
|
$this->installerSvc = $installerSvc;
|
||||||
@ -137,6 +142,7 @@ class UpdateController extends Controller
|
|||||||
|
|
||||||
$release = $this->updateManager->source('github')->fetch($version);
|
$release = $this->updateManager->source('github')->fetch($version);
|
||||||
$this->updateManager->source('github')->update($release);
|
$this->updateManager->source('github')->update($release);
|
||||||
|
$this->analyticsSvc->sendUpdate();
|
||||||
|
|
||||||
Log::info('Update completed to '.$version.', redirecting');
|
Log::info('Update completed to '.$version.', redirecting');
|
||||||
return redirect('/update');
|
return redirect('/update');
|
||||||
|
@ -36,7 +36,8 @@ class ApiTest extends TestCase
|
|||||||
$uri = '/api/user';
|
$uri = '/api/user';
|
||||||
|
|
||||||
// Missing auth header
|
// Missing auth header
|
||||||
$this->get($uri)->assertStatus(401);
|
$res = $this->get($uri);
|
||||||
|
$res->assertStatus(401);
|
||||||
|
|
||||||
// Test invalid API key
|
// Test invalid API key
|
||||||
$this->withHeaders(['Authorization' => 'invalidKey'])->get($uri)
|
$this->withHeaders(['Authorization' => 'invalidKey'])->get($uri)
|
||||||
|
Loading…
Reference in New Issue
Block a user