PHPのdeployerでは、deploy.phpの中で以下のようにallow_anonymous_statsをtrueにしておくことで、deployerの作者にツールの使用統計情報を送信する事ができます。
set('allow_anonymous_stats', true);
この値をtrueにした時、具体的に何の値が送信されるか気になったので調べてみました。
送信される値
実際の送信処理は、deployer/src/Deployer.phpのcollectAnonymousStats()メソッドに記載があり,$statsの配列に格納された情報が送信されるようです。
/**
* Collect anonymous stats about Deployer usage for improving developer experience.
* If you are not comfortable with this, you will always be able to disable this
* by setting `allow_anonymous_stats` to false in your deploy.php file.
*
* @param CommandEvent $commandEvent
* @codeCoverageIgnore
*/
public function collectAnonymousStats(CommandEvent $commandEvent)
{
if ($this->config->has('allow_anonymous_stats') && $this->config['allow_anonymous_stats'] === false) {
return;
}
$stats = [
'status' => 'success',
'command_name' => $commandEvent->getCommand()->getName(),
'project_hash' => empty($this->config['repository']) ? null : sha1($this->config['repository']),
'hosts_count' => $this->hosts->count(),
'deployer_version' => $this->getConsole()->getVersion(),
'deployer_phar' => $this->getConsole()->isPharArchive(),
'php_version' => phpversion(),
'extension_pcntl' => extension_loaded('pcntl'),
'extension_curl' => extension_loaded('curl'),
'os' => defined('PHP_OS_FAMILY') ? PHP_OS_FAMILY : (stristr(PHP_OS, 'DAR') ? 'OSX' : (stristr(PHP_OS, 'WIN') ? 'WIN' : (stristr(PHP_OS, 'LINUX') ? 'LINUX' : PHP_OS))),
'exception' => null,
];
if ($commandEvent->getException() !== null) {
$stats['status'] = 'error';
$stats['exception'] = get_class($commandEvent->getException());
}
if ($stats['command_name'] === 'init') {
$stats['allow_anonymous_stats'] = $GLOBALS['allow_anonymous_stats'] ?? false;
}
if (in_array($stats['command_name'], ['worker', 'list', 'help'], true)) {
return;
}
Reporter::report($stats);
}
allow_anonymous_statsに関する説明
deployerのdep init
コマンドを実行するとdeploy.phpの雛形を作成する事ができるのですが、この途中でallow_anonymous_statsパラメータの説明が以下のように表示されます。
> dep init
...
Contribute to the Deployer Development
In order to help development and improve the features in Deployer,
Deployer has a setting for usage data collection. This function
collects anonymous usage data and sends it to Deployer. The data is
used in Deployer development to get reliable statistics on which
features are used (or not used). The information is not traceable
to any individual or organization. Participation is voluntary,
and you can change your mind at any time.
Anonymous usage data contains Deployer version, php version, os type,
name of the command being executed and whether it was successful or not,
exception class name, count of hosts and anonymized project hash.
If you would like to allow us to gather this information and help
us develop a better tool, please add the code below.
set('allow_anonymous_stats', true);
This function will not affect the performance of Deployer as
the data is insignificant and transmitted in a separate process.
Do you confirm? (yes/no) [yes]:
> yes
こちらもおススメ