forked from repman-io/repman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement telemetry settings (repman-io#225)
* Implement telemetry * Show telemetry documentation link
- Loading branch information
Showing
13 changed files
with
212 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20200716105216 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); | ||
|
||
$this->addSql("INSERT INTO config (key, value) VALUES ('telemetry', 'disabled')"); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); | ||
|
||
$this->addSql("DELETE FROM config WHERE key = 'telemetry'"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buddy\Repman\Service; | ||
|
||
use Ramsey\Uuid\Uuid; | ||
|
||
final class Telemetry | ||
{ | ||
private string $instanceIdFile; | ||
|
||
public function __construct(string $instanceIdFile) | ||
{ | ||
$this->instanceIdFile = $instanceIdFile; | ||
} | ||
|
||
public function docsUrl(): string | ||
{ | ||
return 'https://repman.io/docs/telemetry'; | ||
} | ||
|
||
public function generateInstanceId(): void | ||
{ | ||
if (!$this->isInstanceIdPresent()) { | ||
\file_put_contents($this->instanceIdFile, Uuid::uuid4()); | ||
} | ||
} | ||
|
||
public function isInstanceIdPresent(): bool | ||
{ | ||
return \file_exists($this->instanceIdFile); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div class="alert alert-info"> | ||
<h4>Telemetry</h4> | ||
<p> | ||
Help us improve <strong>Repman</strong> by enabling sending anonymous usage statistic | ||
(<a href="{{ telemetryDocsUrl }}" target="_blank" rel="noopener noreferrer">more info</a>). | ||
</p> | ||
<div class="btn-list"> | ||
<form class="card" action="{{ path('admin_config_telemetry_enable') }}" method="POST"> | ||
<input type="hidden" name="_method" value="POST"> | ||
<button class="btn btn-info" type="submit">Okay</button> | ||
</form> | ||
<form class="card" action="{{ path('admin_config_telemetry_disable') }}" method="POST"> | ||
<input type="hidden" name="_method" value="DELETE"> | ||
<button class="btn btn-secondary" type="submit">No, thanks</button> | ||
</form> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters