From cc907a5aa2393121f20f5d8066cb222f65101d95 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 23 May 2026 18:34:57 -0500 Subject: [PATCH] fix(heartbeat): only send heartbeat for primary domain, not aliases Alias domains were creating separate Grafana datasources with unique UIDs, causing provisioning failures (duplicate UID) when Grafana restarts. Only the primary domain should be registered. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/Extension/MokoWaaS.php | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/src/Extension/MokoWaaS.php b/src/Extension/MokoWaaS.php index 9be73669..9766490d 100644 --- a/src/Extension/MokoWaaS.php +++ b/src/Extension/MokoWaaS.php @@ -2711,8 +2711,9 @@ class MokoWaaS extends CMSPlugin /** * Send heartbeat to the MokoWaaS monitoring receiver. * - * Registers this site (and any aliases) with the Grafana provisioning system. + * Registers this site's primary domain with the Grafana provisioning system. * The receiver writes a datasource YAML file and restarts Grafana. + * Alias domains are not registered to avoid duplicate datasource UIDs. * * @param \Joomla\Registry\Registry $params Plugin params * @param \Joomla\CMS\Application\CMSApplication $app Application @@ -2733,35 +2734,8 @@ class MokoWaaS extends CMSPlugin $siteUrl = rtrim(Uri::root(), '/'); $siteName = Factory::getConfig()->get('sitename', 'Joomla'); - // Register primary domain + // Register primary domain only — aliases should not get separate datasources $this->sendHeartbeat($siteUrl, $siteName, $healthToken, $app); - - // Register any alias domains (subform format: array of objects with domain key) - $aliases = $params->get('site_aliases', ''); - - if (!empty($aliases)) - { - if (is_string($aliases)) - { - $aliases = json_decode($aliases, false); - } - - if (is_array($aliases)) - { - foreach ($aliases as $alias) - { - $alias = (object) $alias; - - if (!empty($alias->domain)) - { - $domain = trim($alias->domain); - $aliasUrl = 'https://' . preg_replace('#^https?://#i', '', $domain); - $aliasUrl = rtrim($aliasUrl, '/'); - $this->sendHeartbeat($aliasUrl, $siteName, $healthToken, $app); - } - } - } - } } /**