From fa7503816af1f7af4f8b5e2761f839260b0b7a69 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Sun, 4 Dec 2022 14:59:45 -0700 Subject: [PATCH] Add telemetry prompt in `p:environment:setup` command --- app/Console/Commands/Environment/AppSettingsCommand.php | 9 ++++++++- app/Console/Kernel.php | 4 ++-- app/Services/Telemetry/TelemetryCollectionService.php | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/Environment/AppSettingsCommand.php b/app/Console/Commands/Environment/AppSettingsCommand.php index 8b9aad48e..e3ffbcfbc 100644 --- a/app/Console/Commands/Environment/AppSettingsCommand.php +++ b/app/Console/Commands/Environment/AppSettingsCommand.php @@ -44,7 +44,8 @@ class AppSettingsCommand extends Command {--redis-host= : Redis host to use for connections.} {--redis-pass= : Password used to connect to redis.} {--redis-port= : Port to connect to redis over.} - {--settings-ui= : Enable or disable the settings UI.}'; + {--settings-ui= : Enable or disable the settings UI.} + {--telemetry= : Enable or disable anonymous telemetry.}'; protected array $variables = []; @@ -119,6 +120,12 @@ class AppSettingsCommand extends Command $this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm('Enable UI based settings editor?', true) ? 'false' : 'true'; } + $this->output->comment('Please reference https://pterodactyl.io/panel/1.0/additional_configuration.html#telemetry for more detailed information regarding telemetry data and collection.'); + $this->variables['PTERODACTYL_TELEMETRY_ENABLED'] = $this->option('telemetry') ?? $this->confirm( + 'Enable sending anonymous telemetry data?', + config('pterodactyl.telemetry.enabled', true) + ) ? 'true' : 'false'; + // Make sure session cookies are set as "secure" when using HTTPS if (str_starts_with($this->variables['APP_URL'], 'https://')) { $this->variables['SESSION_SECURE_COOKIE'] = 'true'; diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a00b17b6d..f79e6c905 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -56,10 +56,10 @@ class Kernel extends ConsoleKernel { $settingsRepository = app()->make(SettingsRepository::class); - $uuid = $settingsRepository->get('app:uuid'); + $uuid = $settingsRepository->get('app:telemetry:uuid'); if (is_null($uuid)) { $uuid = Uuid::uuid4()->toString(); - $settingsRepository->set('app:uuid', $uuid); + $settingsRepository->set('app:telemetry:uuid', $uuid); } // Calculate a fixed time to run the data push at, this will be the same time every day. diff --git a/app/Services/Telemetry/TelemetryCollectionService.php b/app/Services/Telemetry/TelemetryCollectionService.php index ca157694e..6c1b527ef 100644 --- a/app/Services/Telemetry/TelemetryCollectionService.php +++ b/app/Services/Telemetry/TelemetryCollectionService.php @@ -52,10 +52,10 @@ class TelemetryCollectionService */ public function collect(): array { - $uuid = $this->settingsRepository->get('app:uuid'); + $uuid = $this->settingsRepository->get('app:telemetry:uuid'); if (is_null($uuid)) { $uuid = Uuid::uuid4()->toString(); - $this->settingsRepository->set('app:uuid', $uuid); + $this->settingsRepository->set('app:telemetry:uuid', $uuid); } $nodes = Node::all()->map(function ($node) {