$clients]); } qdb_discard($tmpDb, $lockFp); json_error('BAD_REQUEST', 'Unknown query', 400); } catch (Throwable $e) { if (isset($tmpDb, $lockFp)) { qdb_discard($tmpDb, $lockFp); } if (function_exists('qdb_api_log_note_exception')) { qdb_api_log_note_exception($e); } require_once __DIR__ . '/../lib/errors.php'; error_log('analytics GET: ' . $e->getMessage()); json_error('SERVER_ERROR', qdb_public_error_message($e, 'Analytics'), 500); } break; case 'PUT': $body = read_json_body(); $clientCode = trim((string)($body['clientCode'] ?? '')); $note = (string)($body['note'] ?? ''); try { $opened = qdb_open_write_or_fail(); [$pdo, $tmpDb, $lockFp] = $opened; qdb_analytics_set_followup_note($pdo, $tokenRec, $clientCode, $note); qdb_save($tmpDb, $lockFp); json_success(['clientCode' => $clientCode, 'note' => $note]); } catch (Throwable $e) { if (isset($tmpDb, $lockFp)) { qdb_discard($tmpDb, $lockFp); } if (function_exists('qdb_api_log_note_exception')) { qdb_api_log_note_exception($e); } require_once __DIR__ . '/../lib/errors.php'; error_log('analytics PUT: ' . $e->getMessage()); json_error('SERVER_ERROR', qdb_public_error_message($e, 'Save note'), 500); } break; default: json_error('METHOD_NOT_ALLOWED', 'Method not allowed', 405); }