phpvms/app/Services/AnalyticsService.php
2018-08-26 16:40:04 +00:00

46 lines
1.0 KiB
PHP

<?php
namespace App\Services;
use App\Interfaces\Service;
use App\Models\Enums\AnalyticsDimensions;
use DB;
use Irazasyed\LaravelGAMP\Facades\GAMP;
use Log;
use PDO;
/**
* Class AnalyticsService
*/
class AnalyticsService extends Service
{
/**
* Send out some stats about the install
*/
public function sendInstall()
{
if (config('app.analytics') === false) {
return;
}
// some analytics
$gamp = GAMP::setClientId(uniqid('', true));
$gamp->setDocumentPath('/install');
$gamp->setCustomDimension(PHP_VERSION, AnalyticsDimensions::PHP_VERSION);
// figure out database version
$pdo = DB::connection()->getPdo();
$gamp->setCustomDimension(
strtolower($pdo->getAttribute(PDO::ATTR_SERVER_VERSION)),
AnalyticsDimensions::DATABASE_VERSION
);
try {
$gamp->sendPageview();
} catch (\Exception $e) {
Log::error($e->getMessage());
}
}
}