From ef23dd0b08af37655265f606386ce7573e5890f5 Mon Sep 17 00:00:00 2001 From: Agent Date: Thu, 11 Jun 2026 20:39:14 -0400 Subject: [PATCH] fix: add logging to pushMetrics endpoint for debugging 401 --- src/Controllers/ApiController.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Controllers/ApiController.php b/src/Controllers/ApiController.php index 0cb507d..2df23f1 100755 --- a/src/Controllers/ApiController.php +++ b/src/Controllers/ApiController.php @@ -300,7 +300,16 @@ class ApiController public function pushMetrics(): void { - $input = json_decode(file_get_contents('php://input'), true); + $rawBody = file_get_contents('php://input'); + $input = json_decode($rawBody, true); + + $logger = \ServerManager\Core\Logger::getInstance(); + $logger->info('Push metrics received', [ + 'input_keys' => $input ? array_keys($input) : [], + 'has_agent_key' => !empty($input['agent_key']), + 'agent_key_prefix' => isset($input['agent_key']) ? substr((string)$input['agent_key'], 0, 8) . '...' : 'none', + 'raw_body_prefix' => substr($rawBody, 0, 200), + ]); if (!$input || empty($input['agent_key'])) { $this->view->json(['error' => 'agent_key is required'], 401);