Skip to content

Commit

Permalink
Merge pull request #506 from itsmng/telemetry-data
Browse files Browse the repository at this point in the history
Telemetry data
  • Loading branch information
minzords authored Dec 12, 2024
2 parents a3a2629 + 07e1c74 commit ce440f2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
5 changes: 4 additions & 1 deletion ajax/telemetry.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@

if (!($_SESSION['telemetry_from_install'] ?? false)) {
Session::checkRight("config", READ);
$hide_sensitive_data = false;
} else {
$hide_sensitive_data = true;
}

echo Html::css("public/lib/prismjs.css");
echo Html::script("public/lib/prismjs.js");

$infos = Telemetry::getTelemetryInfos();
$infos = Telemetry::getTelemetryInfos($hide_sensitive_data);
echo "<p>" . __("We only collect the following data : plugins usage, performance and responsiveness statistics about user interface features, memory, and hardware configuration.") . "</p>";
echo "<pre><code class='language-json'>";
echo json_encode($infos, JSON_PRETTY_PRINT);
Expand Down
2 changes: 1 addition & 1 deletion inc/define.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

// Last version of GLPI only for plugin compatibility
define('GLPI_VERSION', '9.5.13');
define('ITSM_VERSION', '2.0.2');
define('ITSM_VERSION', '2.0.3');
if (substr(ITSM_VERSION, -4) === '-dev') {
//for dev version
define('ITSM_PREVER', str_replace('-dev', '', ITSM_VERSION));
Expand Down
36 changes: 18 additions & 18 deletions inc/telemetry.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public static function getTypeName($nb = 0)
*
* @return array
*/
public static function getTelemetryInfos()
public static function getTelemetryInfos(bool $hide_sensitive_data = false): array
{
$data = [
'glpi' => self::grabGlpiInfos(),
'glpi' => self::grabGlpiInfos($hide_sensitive_data),
'system' => [
'db' => self::grabDbInfos(),
'web_server' => self::grabWebserverInfos(),
'php' => self::grabPhpInfos(),
'os' => self::grabOsInfos()
'db' => self::grabDbInfos($hide_sensitive_data),
'web_server' => self::grabWebserverInfos($hide_sensitive_data),
'php' => self::grabPhpInfos($hide_sensitive_data),
'os' => self::grabOsInfos($hide_sensitive_data)
]
];

Expand All @@ -67,13 +67,13 @@ public static function getTelemetryInfos()
*
* @return array
*/
public static function grabGlpiInfos()
public static function grabGlpiInfos($hide_sensitive_data = false)
{
global $CFG_GLPI;

$glpi = [
'uuid' => self::getInstanceUuid(),
'version' => ITSM_VERSION,
'uuid' => $hide_sensitive_data ? 'REDACTED' : self::getInstanceUuid(),
'version' => $hide_sensitive_data ? 'REDACTED' : ITSM_VERSION,
'plugins' => [],
'default_language' => $CFG_GLPI['language'],
'install_mode' => GLPI_INSTALL_MODE,
Expand All @@ -97,7 +97,7 @@ public static function grabGlpiInfos()
foreach ($plugins->getList(['directory', 'version']) as $plugin) {
$glpi['plugins'][] = [
'key' => $plugin['directory'],
'version' => $plugin['version']
'version' => $hide_sensitive_data ? 'REDACTED' : $plugin['version']
];
}

Expand All @@ -117,7 +117,7 @@ public static function grabGlpiInfos()
*
* @return array
*/
public static function grabDbInfos()
public static function grabDbInfos($hide_sensitive_data = false)
{
global $DB;

Expand All @@ -131,7 +131,7 @@ public static function grabDbInfos()

$db = [
'engine' => $dbinfos['Server Software'],
'version' => $dbinfos['Server Version'],
'version' => $hide_sensitive_data ? 'REDACTED' : $dbinfos['Server Version'],
'size' => $size_res['dbsize'],
'log_size' => '',
'sql_mode' => $dbinfos['Server SQL Mode']
Expand All @@ -145,7 +145,7 @@ public static function grabDbInfos()
*
* @return array
*/
public static function grabWebserverInfos()
public static function grabWebserverInfos($hide_sensitive_data = false)
{
global $CFG_GLPI;

Expand Down Expand Up @@ -174,7 +174,7 @@ public static function grabWebserverInfos()
$header_matches = [];
if (preg_match('/^Server: (?<engine>[^ ]+)\/(?<version>[^ ]+)/im', $headers, $header_matches)) {
$server['engine'] = $header_matches['engine'];
$server['version'] = $header_matches['version'];
$server['version'] = $hide_sensitive_data ? 'REDACTED' : $header_matches['version'];
}
}

Expand All @@ -186,10 +186,10 @@ public static function grabWebserverInfos()
*
* @return array
*/
public static function grabPhpInfos()
public static function grabPhpInfos($hide_sensitive_data = false)
{
$php = [
'version' => str_replace(PHP_EXTRA_VERSION, '', PHP_VERSION),
'version' => $hide_sensitive_data ? 'REDACTED' : str_replace(PHP_EXTRA_VERSION, '', PHP_VERSION),
'modules' => get_loaded_extensions(),
'setup' => [
'max_execution_time' => ini_get('max_execution_time'),
Expand All @@ -209,7 +209,7 @@ public static function grabPhpInfos()
*
* @return array
*/
public static function grabOsInfos()
public static function grabOsInfos($hide_sensitive_data = false)
{
$distro = false;
if (file_exists('/etc/redhat-release')) {
Expand All @@ -218,7 +218,7 @@ public static function grabOsInfos()
$os = [
'family' => php_uname('s'),
'distribution' => ($distro ?: ''),
'version' => php_uname('r')
'version' => $hide_sensitive_data ? 'REDACTED' : php_uname('r')
];
return $os;
}
Expand Down
1 change: 1 addition & 0 deletions inc/update.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ public function doUpdates($current_version = null)
case "2.0.0":
case "2.0.1":
case "2.0.2":
case "2.0.3":
include_once "{$updir}itsm_update_151_200.php";
update151to200();

Expand Down

0 comments on commit ce440f2

Please sign in to comment.