Files
coolify/app/Actions/Server/ConfigureTrafficAnalytics.php
T
Aditya Tripathi 7c01f63f53 fix(traffic-analytics): stop leaking geoip key and gate sentinel restart
- Only send GEOIP_MAXMIND_LICENSE_KEY to Sentinel when GeoIP is enabled
- Skip restarting Sentinel when disabling analytics unless it was already running
- Validate Sentinel API responses are JSON objects before reading them
- Restore "live" toggle state from localStorage instead of only disabling it
- Use content-based wire:key for breakdown/path rows instead of loop index
- Add missing Kosovo country code and require update permission for geoip listbox
2026-08-21 11:22:36 +00:00

34 lines
1.1 KiB
PHP

<?php
namespace App\Actions\Server;
use App\Actions\Proxy\GetProxyConfiguration;
use App\Jobs\RestartProxyJob;
use App\Models\Server;
use Lorisleiva\Actions\Concerns\AsAction;
class ConfigureTrafficAnalytics
{
use AsAction;
public function handle(Server $server, bool $enable): void
{
$sentinelWasEnabled = (bool) $server->settings->is_sentinel_enabled;
$server->settings->is_traffic_analytics_enabled = $enable;
$server->settings->save();
$server->refresh();
// Regenerate proxy config so the (Traefik) access-log flags / (Caddy) log labels take effect.
GetProxyConfiguration::run($server, forceRegenerate: true);
RestartProxyJob::dispatch($server);
// Recreate Sentinel so it picks up (enabling) or drops (disabling) the traffic env + proxy-log mount.
// Enabling analytics needs Sentinel running; when disabling, only restart if Sentinel was already
// enabled so we never turn Sentinel on as a side effect of disabling analytics.
if ($enable || $sentinelWasEnabled) {
StartSentinel::run($server, restart: true);
}
}
}