Skip to content

Commit

Permalink
Add telemetry prompt in p:environment:setup command
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewpi committed Dec 4, 2022
1 parent 250c557 commit fa75038
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion app/Console/Commands/Environment/AppSettingsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -119,6 +120,12 @@ public function handle(): int
$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';
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ private function registerTelemetry(Schedule $schedule): void
{
$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.
Expand Down
4 changes: 2 additions & 2 deletions app/Services/Telemetry/TelemetryCollectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public function __invoke(): void
*/
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) {
Expand Down

0 comments on commit fa75038

Please sign in to comment.