From 75e7aad5d0fe126a0ae517ce1bf33e0373d6c0c7 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Thu, 19 Mar 2026 00:09:44 -0700 Subject: [PATCH] feat: dual-attempt update check with Supabase install ping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fires a parallel background curl to Supabase during the slow-path version fetch. Logs upgrade_prompted event only on fresh fetches (not cached replays) to avoid overcounting. GitHub remains the primary version source — Supabase ping is fire-and-forget. Co-Authored-By: Claude Opus 4.6 (1M context) --- bin/gstack-update-check | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bin/gstack-update-check b/bin/gstack-update-check index d44c7e0f..0341e202 100755 --- a/bin/gstack-update-check +++ b/bin/gstack-update-check @@ -140,6 +140,20 @@ fi # ─── Step 4: Slow path — fetch remote version ──────────────── mkdir -p "$STATE_DIR" +# Fire Supabase install ping in background (parallel, non-blocking) +# This logs an update check event for community health metrics. +# If the endpoint isn't configured or Supabase is down, this is a no-op. +_SUPA_ENDPOINT="${GSTACK_TELEMETRY_ENDPOINT:-}" +if [ -n "$_SUPA_ENDPOINT" ]; then + _OS="$(uname -s | tr '[:upper:]' '[:lower:]')" + curl -sf --max-time 5 \ + -X POST "${_SUPA_ENDPOINT%/telemetry-ingest}/update-check" \ + -H "Content-Type: application/json" \ + -d "{\"version\":\"$LOCAL\",\"os\":\"$_OS\"}" \ + >/dev/null 2>&1 & +fi + +# GitHub raw fetch (primary, always reliable) REMOTE="" REMOTE="$(curl -sf --max-time 5 "$REMOTE_URL" 2>/dev/null || true)" REMOTE="$(echo "$REMOTE" | tr -d '[:space:]')" @@ -161,4 +175,12 @@ echo "UPGRADE_AVAILABLE $LOCAL $REMOTE" > "$CACHE_FILE" if check_snooze "$REMOTE"; then exit 0 # snoozed — stay quiet fi + +# Log upgrade_prompted event (only on slow-path fetch, not cached replays) +TEL_CMD="$GSTACK_DIR/bin/gstack-telemetry-log" +if [ -x "$TEL_CMD" ]; then + "$TEL_CMD" --event-type upgrade_prompted --skill "" --duration 0 \ + --outcome success --session-id "update-$$-$(date +%s)" 2>/dev/null & +fi + echo "UPGRADE_AVAILABLE $LOCAL $REMOTE"