mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
fix(install): honor resolved telemetry opt-out and DO_NOT_TRACK=yes
Check _APP_TELEMETRY from resolved installer input (existing .env) and accept the standard DO_NOT_TRACK=yes value so upgrade pings respect opt-out. Co-authored-by: Chirag Aggarwal <chiragaggarwal5k@gmail.com>
This commit is contained in:
1 parent
c3c1f703e8
commit
14acd9e3c2
2 files changed
+37
-5
No files matched your search
@@ -881,7 +881,7 @@ class Install extends Action
|
||||
*/
|
||||
public function buildSelfHostedInstallPayload(array $input, bool $isUpgrade, string $version): ?array
|
||||
{
|
||||
if ($this->isTelemetryDisabled()) {
|
||||
if ($this->isTelemetryDisabled($input)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -928,16 +928,31 @@ class Install extends Action
|
||||
/**
|
||||
* Whether the operator opted out of anonymous install/upgrade telemetry.
|
||||
*
|
||||
* Honors DO_NOT_TRACK (https://consoledonottrack.com) and _APP_TELEMETRY=disabled.
|
||||
* Honors DO_NOT_TRACK (https://consoledonottrack.com) and _APP_TELEMETRY=disabled
|
||||
* from the process environment or resolved installer `$input` (e.g. existing `.env`).
|
||||
*
|
||||
* @param array<string, mixed>|null $input Resolved environment variables
|
||||
*/
|
||||
public function isTelemetryDisabled(): bool
|
||||
public function isTelemetryDisabled(?array $input = null): bool
|
||||
{
|
||||
$doNotTrack = \strtolower((string) System::getEnv('DO_NOT_TRACK', ''));
|
||||
if ($doNotTrack === '1' || $doNotTrack === 'true') {
|
||||
if (\in_array($doNotTrack, ['1', 'true', 'yes'], true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return \strtolower((string) System::getEnv('_APP_TELEMETRY', '')) === 'disabled';
|
||||
$telemetry = \strtolower((string) System::getEnv('_APP_TELEMETRY', ''));
|
||||
if ($telemetry === 'disabled') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($input !== null) {
|
||||
$fromInput = \strtolower((string) ($input['_APP_TELEMETRY'] ?? ''));
|
||||
if ($fromInput === 'disabled') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,6 +87,14 @@ final class InstallTest extends TestCase
|
||||
$this->assertTrue($this->install->isTelemetryDisabled());
|
||||
}
|
||||
|
||||
public function testDoNotTrackYesValueDisablesTelemetry(): void
|
||||
{
|
||||
\putenv('DO_NOT_TRACK=yes');
|
||||
|
||||
$this->assertTrue($this->install->isTelemetryDisabled());
|
||||
$this->assertNull($this->install->buildSelfHostedInstallPayload($this->productionInput(), false, '1.9.6'));
|
||||
}
|
||||
|
||||
public function testAppTelemetryDisabledDisablesTelemetry(): void
|
||||
{
|
||||
\putenv('_APP_TELEMETRY=disabled');
|
||||
@@ -95,6 +103,15 @@ final class InstallTest extends TestCase
|
||||
$this->assertNull($this->install->buildSelfHostedInstallPayload($this->productionInput(), false, '1.9.6'));
|
||||
}
|
||||
|
||||
public function testResolvedInputTelemetryDisabledDisablesTelemetry(): void
|
||||
{
|
||||
$input = $this->productionInput();
|
||||
$input['_APP_TELEMETRY'] = 'disabled';
|
||||
|
||||
$this->assertTrue($this->install->isTelemetryDisabled($input));
|
||||
$this->assertNull($this->install->buildSelfHostedInstallPayload($input, false, '1.9.6'));
|
||||
}
|
||||
|
||||
public function testTelemetryEnabledByDefault(): void
|
||||
{
|
||||
$this->assertFalse($this->install->isTelemetryDisabled());
|
||||
|
||||
Reference in new issue
Block a user