diff --git a/apps/cli-go/cmd/root.go b/apps/cli-go/cmd/root.go index f83eb6d11b..0cae854b62 100644 --- a/apps/cli-go/cmd/root.go +++ b/apps/cli-go/cmd/root.go @@ -8,6 +8,7 @@ import ( "net/url" "os" "os/signal" + "strconv" "strings" "sync" "time" @@ -184,6 +185,9 @@ func Execute() { panic(err) } // Check upgrade last because --version flag is initialised after execute + if shouldSkipUpdateNotifier() { + return + } ctx := rootCmd.Context() if executedCmd != nil { ctx = executedCmd.Context() @@ -203,6 +207,15 @@ func Execute() { } } +func shouldSkipUpdateNotifier() bool { + val := os.Getenv("SUPABASE_NO_UPDATE_NOTIFIER") + if len(val) == 0 { + return false + } + enabled, err := strconv.ParseBool(val) + return err == nil && enabled +} + // ensureProjectGroupsCached populates the telemetry linked-project cache when // a project ref is available but no cache exists. This ensures org/project // PostHog groups are attached to all CLI events, not just those after `supabase link`. diff --git a/apps/cli-go/cmd/root_test.go b/apps/cli-go/cmd/root_test.go index fa7c6f39d7..e38c339726 100644 --- a/apps/cli-go/cmd/root_test.go +++ b/apps/cli-go/cmd/root_test.go @@ -119,3 +119,26 @@ func TestEnvSignals(t *testing.T) { assert.Equal(t, strings.Repeat("x", 80), signals["TERM"]) assert.NotContains(t, signals, "AI_AGENT") } + +func TestShouldSkipUpdateNotifier(t *testing.T) { + t.Run("returns true when SUPABASE_NO_UPDATE_NOTIFIER is true", func(t *testing.T) { + t.Setenv("SUPABASE_NO_UPDATE_NOTIFIER", "true") + assert.True(t, shouldSkipUpdateNotifier()) + }) + + t.Run("returns true when SUPABASE_NO_UPDATE_NOTIFIER is 1", func(t *testing.T) { + t.Setenv("SUPABASE_NO_UPDATE_NOTIFIER", "1") + assert.True(t, shouldSkipUpdateNotifier()) + }) + + t.Run("returns false when SUPABASE_NO_UPDATE_NOTIFIER is false", func(t *testing.T) { + t.Setenv("SUPABASE_NO_UPDATE_NOTIFIER", "false") + assert.False(t, shouldSkipUpdateNotifier()) + }) + + t.Run("returns false when SUPABASE_NO_UPDATE_NOTIFIER is unset", func(t *testing.T) { + t.Setenv("SUPABASE_NO_UPDATE_NOTIFIER", "") + assert.False(t, shouldSkipUpdateNotifier()) + }) +} +