mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Better generation of installation ID.
This commit is contained in:
parent
d493820cc8
commit
f5c075936f
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Console\Commands;
|
namespace FireflyIII\Console\Commands;
|
||||||
|
|
||||||
|
use FireflyIII\Support\System\GeneratesInstallationId;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +33,8 @@ use Illuminate\Console\Command;
|
|||||||
*/
|
*/
|
||||||
class UpgradeFireflyInstructions extends Command
|
class UpgradeFireflyInstructions extends Command
|
||||||
{
|
{
|
||||||
|
use GeneratesInstallationId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
@ -50,6 +53,7 @@ class UpgradeFireflyInstructions extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
|
$this->generateInstallationId();
|
||||||
if ('update' === (string) $this->argument('task')) {
|
if ('update' === (string) $this->argument('task')) {
|
||||||
$this->updateInstructions();
|
$this->updateInstructions();
|
||||||
}
|
}
|
||||||
@ -64,6 +68,7 @@ class UpgradeFireflyInstructions extends Command
|
|||||||
app('telemetry')->feature('system.database.driver', env('DB_CONNECTION', '(unknown)'));
|
app('telemetry')->feature('system.database.driver', env('DB_CONNECTION', '(unknown)'));
|
||||||
app('telemetry')->feature('system.os.is_docker', $isDocker);
|
app('telemetry')->feature('system.os.is_docker', $isDocker);
|
||||||
app('telemetry')->feature('system.command.executed', $this->signature);
|
app('telemetry')->feature('system.command.executed', $this->signature);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,7 @@ namespace FireflyIII\Http\Middleware;
|
|||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use Log;
|
use FireflyIII\Support\System\GeneratesInstallationId;
|
||||||
use Ramsey\Uuid\Uuid;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -35,6 +34,7 @@ use Ramsey\Uuid\Uuid;
|
|||||||
*/
|
*/
|
||||||
class InstallationId
|
class InstallationId
|
||||||
{
|
{
|
||||||
|
use GeneratesInstallationId;
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
*
|
||||||
@ -48,13 +48,7 @@ class InstallationId
|
|||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
$config = app('fireflyconfig')->get('installation_id', null);
|
$this->generateInstallationId();
|
||||||
if (null === $config) {
|
|
||||||
$uuid5 = Uuid::uuid5(Uuid::NAMESPACE_URL, 'firefly-iii.org');
|
|
||||||
$uniqueId = (string) $uuid5;
|
|
||||||
Log::info(sprintf('Created Firefly III installation ID %s', $uniqueId));
|
|
||||||
app('fireflyconfig')->set('installation_id', $uniqueId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
28
app/Support/System/GeneratesInstallationId.php
Normal file
28
app/Support/System/GeneratesInstallationId.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Support\System;
|
||||||
|
|
||||||
|
use Log;
|
||||||
|
use Ramsey\Uuid\Uuid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trait GeneratesInstallationId
|
||||||
|
*/
|
||||||
|
trait GeneratesInstallationId
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected function generateInstallationId(): void
|
||||||
|
{
|
||||||
|
$config = app('fireflyconfig')->get('installation_id', null);
|
||||||
|
if (null === $config) {
|
||||||
|
$uuid5 = Uuid::uuid5(Uuid::NAMESPACE_URL, 'firefly-iii.org');
|
||||||
|
$uniqueId = (string) $uuid5;
|
||||||
|
Log::info(sprintf('Created Firefly III installation ID %s', $uniqueId));
|
||||||
|
app('fireflyconfig')->set('installation_id', $uniqueId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -24,6 +24,7 @@ namespace FireflyIII\Support;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Models\Telemetry as TelemetryModel;
|
use FireflyIII\Models\Telemetry as TelemetryModel;
|
||||||
|
use FireflyIII\Support\System\GeneratesInstallationId;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@ -32,6 +33,7 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class Telemetry
|
class Telemetry
|
||||||
{
|
{
|
||||||
|
use GeneratesInstallationId;
|
||||||
/**
|
/**
|
||||||
* Feature telemetry stores a $value for the given $feature.
|
* Feature telemetry stores a $value for the given $feature.
|
||||||
* Will only store the given $feature / $value combination once.
|
* Will only store the given $feature / $value combination once.
|
||||||
@ -166,9 +168,12 @@ class Telemetry
|
|||||||
*/
|
*/
|
||||||
private function storeEntry(string $type, string $name, string $value): void
|
private function storeEntry(string $type, string $name, string $value): void
|
||||||
{
|
{
|
||||||
|
$this->generateInstallationId();
|
||||||
|
$config = app('fireflyconfig')->get('installation_id', null);
|
||||||
|
$installationId = null !== $config ? $config->data : 'empty';
|
||||||
TelemetryModel::create(
|
TelemetryModel::create(
|
||||||
[
|
[
|
||||||
'installation_id' => \FireflyConfig::get('installation_id', '')->data,
|
'installation_id' => $installationId,
|
||||||
'key' => $name,
|
'key' => $name,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
|
Loading…
Reference in New Issue
Block a user