feat: heartbeat sends full health payload and client info
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Report Issues (push) Has been cancelled
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Universal: Auto Version Bump / Version Bump (push) Has been cancelled
Platform: moko-platform CI / Gate 1: Code Quality (push) Has been cancelled

Monitor plugin now includes live health data (16 checks) and client
info (company name, email from Joomla config) in the heartbeat payload.
Health data is fetched via local HTTP call to /?mokowaas=health to
reuse existing auth and check logic without internal coupling.

MokoWaaSBase can use client_info for auto-contact creation and the
health payload for dashboard visualization without separate polling.

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-06-06 11:01:33 -05:00
parent 509470b20b
commit db2ed26e65
@@ -109,16 +109,30 @@ class Monitor extends CMSPlugin implements SubscriberInterface
$app = $this->getApplication();
$config = Factory::getConfig();
$payload = [
'token' => $healthToken,
'domain' => $domain,
'site_name' => Factory::getConfig()->get('sitename', 'Joomla'),
'site_url' => $siteUrl,
'joomla_version' => (new Version())->getShortVersion(),
'php_version' => PHP_VERSION,
'token' => $healthToken,
'domain' => $domain,
'site_name' => $config->get('sitename', 'Joomla'),
'site_url' => $siteUrl,
'joomla_version' => (new Version())->getShortVersion(),
'php_version' => PHP_VERSION,
'mokowaas_version' => $this->getMokoWaaSVersion(),
'client_info' => [
'company' => $config->get('sitename', ''),
'email' => $config->get('mailfrom', ''),
],
];
// Include live health data by calling the local health endpoint
$healthData = $this->fetchLocalHealth($siteUrl, $healthToken);
if ($healthData !== null)
{
$payload['health'] = $healthData;
}
$endpoint = $baseUrl . '/api/index.php/v1/mokowaasbase/heartbeat';
$json = json_encode($payload, JSON_UNESCAPED_SLASHES);
@@ -165,6 +179,42 @@ class Monitor extends CMSPlugin implements SubscriberInterface
}
}
/**
* Fetch health data from the local site's health endpoint.
*
* @param string $siteUrl Local site URL.
* @param string $healthToken Health API token.
*
* @return array|null Parsed health data or null on failure.
*/
private function fetchLocalHealth(string $siteUrl, string $healthToken): ?array
{
$url = $siteUrl . '/?mokowaas=health';
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $healthToken,
'Accept: application/json',
],
]);
$response = curl_exec($ch);
$code = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($code !== 200 || empty($response))
{
return null;
}
return json_decode($response, true) ?: null;
}
/**
* Get the installed MokoWaaS package version.
*/