Gate telemetry debug via DEV_MODE

Replace unconditional debug echoes in misc/api.func with checks on DEV_MODE so telemetry debug output is only shown when DEV_MODE=true. Make curl fire-and-forget: verbose HTTP code and payload logging only in DEV_MODE, while production uses a silent curl invocation that never blocks or fails. Remove a stray trailing whitespace in detect_ram. Add misc/data/telemetry-ingest.exe binary to repo.
This commit is contained in:
CanbiZ (MickLesk) 2026-02-11 07:55:02 +01:00
parent 0876c417d3
commit 54f59505d1

View File

@ -284,24 +284,21 @@ detect_ram() {
# - Never blocks or fails script execution
# ------------------------------------------------------------------------------
post_to_api() {
# DEBUG: Show function entry
echo "[DEBUG] post_to_api() called" >&2
# Silent fail - telemetry should never break scripts
command -v curl &>/dev/null || {
echo "[DEBUG] curl not found, skipping" >&2
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] curl not found, skipping" >&2
return 0
}
[[ "${DIAGNOSTICS:-no}" == "no" ]] && {
echo "[DEBUG] DIAGNOSTICS=no, skipping" >&2
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] DIAGNOSTICS=no, skipping" >&2
return 0
}
[[ -z "${RANDOM_UUID:-}" ]] && {
echo "[DEBUG] RANDOM_UUID empty, skipping" >&2
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] RANDOM_UUID empty, skipping" >&2
return 0
}
echo "[DEBUG] Checks passed: DIAGNOSTICS=$DIAGNOSTICS RANDOM_UUID=$RANDOM_UUID NSAPP=$NSAPP" >&2
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] post_to_api() DIAGNOSTICS=$DIAGNOSTICS RANDOM_UUID=$RANDOM_UUID NSAPP=$NSAPP" >&2
# Set type for later status updates
TELEMETRY_TYPE="lxc"
@ -358,16 +355,21 @@ post_to_api() {
EOF
)
echo "[DEBUG] Sending to: $TELEMETRY_URL" >&2
echo "[DEBUG] Payload: $JSON_PAYLOAD" >&2
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] Sending to: $TELEMETRY_URL" >&2
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] Payload: $JSON_PAYLOAD" >&2
# Fire-and-forget: never block, never fail
local http_code
if [[ "${DEV_MODE:-}" == "true" ]]; then
http_code=$(curl -sS -w "%{http_code}" -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" -o /dev/stderr 2>&1) || true
echo "[DEBUG] HTTP response code: $http_code" >&2
else
curl -fsS -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" &>/dev/null || true
fi
}
# ------------------------------------------------------------------------------