Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/update-report: nudge people to tweak settings. #14592

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 90 additions & 24 deletions Library/Homebrew/cmd/update-report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,21 @@
exec HOMEBREW_BREW_FILE, "update", *update_args
end

if !Utils::Analytics.messages_displayed? &&
!Utils::Analytics.disabled? &&
!Utils::Analytics.no_message_output?

ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
# Use the shell's audible bell.
print "\a"

# Use an extra newline and bold to avoid this being missed.
ohai "Homebrew has enabled anonymous aggregate formula and cask analytics."
puts <<~EOS
#{Tty.bold}Read the analytics documentation (and how to opt-out) here:
#{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset}
No analytics have been recorded yet (nor will be during this `brew` run).

EOS

# Consider the messages possibly missed if not a TTY.
Utils::Analytics.messages_displayed! if $stdout.tty?
if ENV["HOMEBREW_ADDITIONAL_GOOGLE_ANALYTICS_ID"].present?
opoo "HOMEBREW_ADDITIONAL_GOOGLE_ANALYTICS_ID is now a no-op so can be unset."
puts "All Homebrew Google Analytics code and data was destroyed."

Check warning on line 88 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L88

Added line #L88 was not covered by tests
end

if Settings.read("donationmessage") != "true" && !args.quiet?
ohai "Homebrew is run entirely by unpaid volunteers. Please consider donating:"
puts " #{Formatter.url("https://github.com/Homebrew/brew#donations")}\n\n"
if ENV["HOMEBREW_NO_GOOGLE_ANALYTICS"].present?
opoo "HOMEBREW_NO_GOOGLE_ANALYTICS is now a no-op so can be unset."
puts "All Homebrew Google Analytics code and data was destroyed."

Check warning on line 93 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L93

Added line #L93 was not covered by tests
end

# Consider the message possibly missed if not a TTY.
Settings.write "donationmessage", true if $stdout.tty?
unless args.quiet?
analytics_message
donation_message
install_from_api_message
untap_message

Check warning on line 100 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L98-L100

Added lines #L98 - L100 were not covered by tests
end

install_core_tap_if_necessary
Expand Down Expand Up @@ -339,6 +327,84 @@
def migrate_gcc_dependents_if_needed
# do nothing
end

def analytics_message
if !Utils::Analytics.messages_displayed? &&

Check warning on line 332 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L332

Added line #L332 was not covered by tests
!Utils::Analytics.disabled? &&
!Utils::Analytics.no_message_output?

ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
# Use the shell's audible bell.
print "\a"

Check warning on line 338 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L338

Added line #L338 was not covered by tests

# Use an extra newline and bold to avoid this being missed.
ohai "Homebrew collects anonymous analytics."
puts <<~EOS

Check warning on line 342 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L341-L342

Added lines #L341 - L342 were not covered by tests
#{Tty.bold}Read the analytics documentation (and how to opt-out) here:
#{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset}
No analytics have been recorded yet (nor will be during this `brew` run).

EOS

# Consider the messages possibly missed if not a TTY.
Utils::Analytics.messages_displayed! if $stdout.tty?
elsif Utils::Analytics.disabled?
ohai "Homebrew's analytics have entirely moved to our InfluxDB instance in the EU."
puts "We gather less data than before and have destroyed all Google Analytics data:"
puts " #{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset}"
puts "Please reconsider re-enabling analytics to help our volunteer maintainers with:"
puts " brew analytics on"

Check warning on line 356 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L353-L356

Added lines #L353 - L356 were not covered by tests

# Consider the message possibly missed if not a TTY.
Settings.write "influxanalyticsmessage", true if $stdout.tty?
end
end

def donation_message
return if Settings.read("donationmessage") == "true"

ohai "Homebrew is run entirely by unpaid volunteers. Please consider donating:"
puts " #{Formatter.url("https://github.com/Homebrew/brew#donations")}\n\n"

Check warning on line 367 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L366-L367

Added lines #L366 - L367 were not covered by tests

# Consider the message possibly missed if not a TTY.
Settings.write "donationmessage", true if $stdout.tty?
end

def install_from_api_message
return if Settings.read("installfromapimessage") == "true"

auto_update_secs_set = Homebrew::EnvConfig.api_auto_update_secs.to_i.positive?

Check warning on line 376 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L376

Added line #L376 was not covered by tests
if !Homebrew::EnvConfig.no_auto_update? && !Homebrew::EnvConfig.no_install_from_api? && !auto_update_secs_set
return
end

ohai "You have set:"

Check warning on line 381 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L381

Added line #L381 was not covered by tests
puts " HOMEBREW_NO_AUTO_UPDATE" if Homebrew::EnvConfig.no_auto_update?
puts " HOMEBREW_API_AUTO_UPDATE_SECS" if auto_update_secs_set
if Homebrew::EnvConfig.no_install_from_api? && !Homebrew::EnvConfig.automatically_set_no_install_from_api?
puts " HOMEBREW_NO_INSTALL_FROM_API"
end
puts "but we have dramatically sped up and fixed many bugs in the way we do Homebrew updates since."
puts "Please consider unsetting these and tweaking the values based on the new behaviour."
puts "\n\n"

Check warning on line 389 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L387-L389

Added lines #L387 - L389 were not covered by tests

# Consider the message possibly missed if not a TTY.
Settings.write "installfromapimessage", true if $stdout.tty?
end

def untap_message
return if Homebrew::EnvConfig.no_install_from_api?
return if Homebrew::EnvConfig.developer? || ENV["HOMEBREW_DEV_CMD_RUN"]

core_tap = CoreTap.instance
cask_tap = Tap.default_cask_tap

Check warning on line 400 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L399-L400

Added lines #L399 - L400 were not covered by tests
return if !core_tap.installed? && !cask_tap.installed?
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved

puts "Installing from the API is now the default behaviour!"
puts "You can save space and time by running:"

Check warning on line 404 in Library/Homebrew/cmd/update-report.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-report.rb#L403-L404

Added lines #L403 - L404 were not covered by tests
puts " brew untap #{core_tap.name}" if core_tap.installed?
puts " brew untap #{cask_tap.name}" if cask_tap.installed?
end
end

require "extend/os/cmd/update-report"
Expand Down
Loading