Skip to content

Commit

Permalink
BLT-5196: Remove telemetry (#4643)
Browse files Browse the repository at this point in the history
* BLT-5196: Remove telemetry

* code style
  • Loading branch information
danepowell authored Dec 23, 2022
1 parent 419c51b commit 31451b4
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 249 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"symfony/console": "^4.4.6 || ^6",
"symfony/twig-bridge": "^3.4 || ^4 || ^5 || ^6",
"symfony/yaml": "^4.4 || ^5 || ^6",
"webmozart/path-util": "^2.3",
"zumba/amplitude-php": "^1.0.3"
"webmozart/path-util": "^2.3"
},
"conflict": {
"acquia/blt-behat": "<=1.0.0"
Expand Down
63 changes: 1 addition & 62 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 5 additions & 28 deletions src/Robo/Blt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace Acquia\Blt\Robo;

use Acquia\Blt\Robo\Common\EnvironmentDetector;
use Acquia\Blt\Robo\Common\Executor;
use Acquia\Blt\Robo\Common\IO;
use Acquia\Blt\Robo\Common\UserConfig;
use Acquia\Blt\Robo\Filesets\FilesetManager;
use Acquia\Blt\Robo\Inspector\Inspector;
use Acquia\Blt\Robo\Inspector\InspectorAwareInterface;
Expand All @@ -28,7 +26,6 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Zumba\Amplitude\Amplitude;

/**
* The BLT Robo application.
Expand Down Expand Up @@ -96,7 +93,6 @@ public function __construct(

$this->setLogger($container->get('logger'));

$this->initializeAmplitude();
}

/**
Expand All @@ -113,20 +109,6 @@ public static function getVersion() {
return 'Unknown';
}

/**
* Initializes Amplitude.
*/
private function initializeAmplitude() {
$userConfig = new UserConfig(self::configDir());
$amplitude = Amplitude::getInstance();
$amplitude->init('dfd3cba7fa72065cde9edc2ca22d0f37')
->setDeviceId(EnvironmentDetector::getMachineUuid());
if (!$userConfig->isTelemetryEnabled()) {
$amplitude->setOptOut(TRUE);
}
$amplitude->logQueuedEvents();
}

/**
* Add the commands and hooks which are shipped with core BLT.
*/
Expand Down Expand Up @@ -258,18 +240,13 @@ public function configureContainer($container) {
*
* @return int
* The exiting status code of the application
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
public function run(InputInterface $input, OutputInterface $output) {
public function run(InputInterface $input, OutputInterface $output): int {
$application = $this->getContainer()->get('application');
$status_code = $this->runner->run($input, $output, $application, $this->commands);

$userConfig = new UserConfig(self::configDir());
$event_properties = $userConfig->getTelemetryUserData();
$event_properties['exit_code'] = $status_code;
$event_properties['command'] = $input->getFirstArgument();
Amplitude::getInstance()->queueEvent('run command', $event_properties);

return $status_code;
return $this->runner->run($input, $output, $application, $this->commands);
}

/**
Expand Down
10 changes: 2 additions & 8 deletions src/Robo/Commands/Blt/TelemetryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Acquia\Blt\Robo\Commands\Blt;

use Acquia\Blt\Robo\Blt;
use Acquia\Blt\Robo\BltTasks;
use Acquia\Blt\Robo\Common\UserConfig;

/**
* Defines commands in the 'blt:telemetry' namespace.
Expand All @@ -17,9 +15,7 @@ class TelemetryCommand extends BltTasks {
* @command blt:telemetry:enable
*/
public function telemetryEnable() {
$userConfig = new UserConfig(Blt::configDir());
$userConfig->setTelemetryEnabled(TRUE);
$this->say($userConfig::OPT_IN_MESSAGE);
$this->say('Telemetry has been removed from BLT, this command does nothing.');
}

/**
Expand All @@ -28,9 +24,7 @@ public function telemetryEnable() {
* @command blt:telemetry:disable
*/
public function telemetryDisable() {
$userConfig = new UserConfig(Blt::configDir());
$userConfig->setTelemetryEnabled(FALSE);
$this->say($userConfig::OPT_OUT_MESSAGE);
$this->say('Telemetry has been removed from BLT, this command does nothing.');
}

}
8 changes: 0 additions & 8 deletions src/Robo/Commands/Drupal/ConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

namespace Acquia\Blt\Robo\Commands\Drupal;

use Acquia\Blt\Robo\Blt;
use Acquia\Blt\Robo\BltTasks;
use Acquia\Blt\Robo\Common\UserConfig;
use Acquia\Blt\Robo\Exceptions\BltException;
use Symfony\Component\Yaml\Yaml;
use Zumba\Amplitude\Amplitude;

/**
* Defines commands in the "setup:config*" namespace.
Expand Down Expand Up @@ -58,11 +55,6 @@ public function update(): void {
public function import() {
$strategy = $this->getConfigValue('cm.strategy');

$userConfig = new UserConfig(Blt::configDir());
$eventInfo = $userConfig->getTelemetryUserData();
$eventInfo['strategy'] = $strategy;
Amplitude::getInstance()->queueEvent('config import', $eventInfo);

if ($strategy === 'none') {
// Still clear caches to regenerate frontend assets and such.
return $this->taskDrush()->drush("cache-rebuild")->run();
Expand Down
115 changes: 0 additions & 115 deletions src/Robo/Common/UserConfig.php

This file was deleted.

26 changes: 0 additions & 26 deletions src/Robo/Hooks/CommandEventHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Acquia\Blt\Robo\Hooks;

use Acquia\Blt\Robo\Blt;
use Acquia\Blt\Robo\BltTasks;
use Acquia\Blt\Robo\Common\UserConfig;
use Symfony\Component\Console\Event\ConsoleCommandEvent;

/**
Expand Down Expand Up @@ -43,28 +41,4 @@ public function issueWarnings(ConsoleCommandEvent $event) {
$this->getInspector()->issueEnvironmentWarnings($command_name);
}

/**
* Ask users to set a telemetry preference.
*
* @hook command-event *
*/
public function telemetry(ConsoleCommandEvent $event) {
$userConfig = new UserConfig(Blt::configDir());

// Ask to enable telemetry if necessary.
if (!$userConfig->isTelemetrySet() && $this->input()->isInteractive()) {
$this->say("We strive to give you the best tools for development.\nYou can really help us improve by sharing anonymous performance and usage data.\n");
$preference = $this->confirm("Do you want to help us make this tool even better?", TRUE);
$userConfig->setTelemetryEnabled($preference);
if ($preference) {
$this->say($userConfig::OPT_IN_MESSAGE);
}
else {
$this->say($userConfig::OPT_OUT_MESSAGE);
}
sleep(2);
}

}

}

0 comments on commit 31451b4

Please sign in to comment.