- Модуль: imbot
- Путь к файлу: ~/bitrix/modules/imbot/lib/bot/supportbox.php
- Класс: BitrixImBotBotSupportBox
- Вызов: SupportBox::sendTelemetry
static function sendTelemetry($messageFields): bool
{
$modulesInfo = ModuleManager::getInstalledModules();
foreach ($modulesInfo as $key => $mi)
{
$modulesInfo[$key]['VERSION'] = ModuleManager::getVersion($key);
}
$siteCheckerTest = new CSiteCheckerTest();
$filePath = $_SERVER['DOCUMENT_ROOT'] . $siteCheckerTest->LogFile;
try
{
$logFile = new File($filePath);
$lastCheckDate = (new DateTimeImmutable)->setTimestamp($logFile->getModificationTime());
$logContents = htmlspecialcharsEx($logFile->getContents());
}
catch (FileNotFoundException $exception)
{
self::clientMessageAdd([
'BOT_ID' => self::getBotId(),
'USER_ID' => $messageFields['FROM_USER_ID'],
'DIALOG_ID' => $messageFields['DIALOG_ID'],
'MESSAGE' => [
'TEXT' => Loc::getMessage('TELEMETRY_NO_CHECK_NEVER_BEEN_DONE'),
],
'EXTRA_DATA' => [
'MODULES_INFO' => $modulesInfo,
],
'PARAMS' => [
'CLASS' => 'bx-messenger-content-item-system',
'TELEMETRY' => 'Y',
],
]);
return false;
}
if ($failsCount = substr_count($logContents, 'Fail'))
{
$text = Loc::getMessagePlural(
'TELEMETRY_ALL_FAIL',
$failsCount,
[
'#DATE#' => $lastCheckDate->format('Y-m-d H:i'),
'#FAILS_COUNT#' => $failsCount
]
);
}
else
{
$text = Loc::getMessage(
'TELEMETRY_ALL_OK',
[
'#DATE#' => $lastCheckDate->format('Y-m-d H:i')
]
);
}
self::clientMessageAdd([
'BOT_ID' => self::getBotId(),
'USER_ID' => $messageFields['FROM_USER_ID'],
'DIALOG_ID' => $messageFields['DIALOG_ID'],
'MESSAGE' => [
'TEXT' => $text,
],
'EXTRA_DATA' => [
'MODULES_INFO' => $modulesInfo,
],
'FILES_RAW' => [
[
'NAME' => 'site_checker.log',
'TYPE' => 'text/x-log',
'DATA' => $logContents,
],
],
'PARAMS' => [
'CLASS' => 'bx-messenger-content-item-system',
'TELEMETRY' => 'Y',
]
]);
return true;
}