mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-05 13:15:24 +02:00
feat: dual-attempt update check with Supabase install ping
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user