2018-01-30 03:16:39 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Service;
|
2018-02-21 12:33:09 +08:00
|
|
|
use App\Models\Enums\AnalyticsDimensions;
|
2019-09-17 01:08:26 +08:00
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
2018-02-21 12:33:09 +08:00
|
|
|
use Irazasyed\LaravelGAMP\Facades\GAMP;
|
2018-01-30 03:16:39 +08:00
|
|
|
use PDO;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
class AnalyticsService extends Service
|
2018-01-30 03:16:39 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Send out some stats about the install
|
|
|
|
*/
|
|
|
|
public function sendInstall()
|
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
if (config('app.analytics') === false) {
|
2018-01-30 03:16:39 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-27 00:40:04 +08:00
|
|
|
// some analytics
|
2018-01-30 03:16:39 +08:00
|
|
|
$gamp = GAMP::setClientId(uniqid('', true));
|
|
|
|
$gamp->setDocumentPath('/install');
|
|
|
|
|
|
|
|
$gamp->setCustomDimension(PHP_VERSION, AnalyticsDimensions::PHP_VERSION);
|
|
|
|
|
2018-08-27 00:40:04 +08:00
|
|
|
// figure out database version
|
2018-01-30 03:16:39 +08:00
|
|
|
$pdo = DB::connection()->getPdo();
|
|
|
|
$gamp->setCustomDimension(
|
|
|
|
strtolower($pdo->getAttribute(PDO::ATTR_SERVER_VERSION)),
|
|
|
|
AnalyticsDimensions::DATABASE_VERSION
|
|
|
|
);
|
|
|
|
|
2018-02-12 23:47:12 +08:00
|
|
|
try {
|
|
|
|
$gamp->sendPageview();
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
Log::error($e->getMessage());
|
|
|
|
}
|
2018-01-30 03:16:39 +08:00
|
|
|
}
|
|
|
|
}
|