Fix (again) InfluxDB analytics messaging

Address https://github.com/Homebrew/brew/pull/15688#issuecomment-1638725595

Fixes https://github.com/Homebrew/brew/issues/15678
This commit is contained in:
Mike McQuaid 2023-07-18 08:03:57 +01:00
parent 8bfe579e8a
commit 77061817f7
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
2 changed files with 17 additions and 16 deletions

View File

@ -329,10 +329,16 @@ module Homebrew
end end
def analytics_message def analytics_message
if !Utils::Analytics.messages_displayed? && return if Utils::Analytics.messages_displayed?
!Utils::Analytics.disabled? && return if Utils::Analytics.no_message_output?
!Utils::Analytics.no_message_output?
if Utils::Analytics.disabled? && !Utils::Analytics.influx_message_displayed?
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"
elsif !Utils::Analytics.disabled?
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
# Use the shell's audible bell. # Use the shell's audible bell.
print "\a" print "\a"
@ -345,19 +351,10 @@ module Homebrew
No analytics have been recorded yet (nor will be during this `brew` run). No analytics have been recorded yet (nor will be during this `brew` run).
EOS EOS
end
# Consider the messages possibly missed if not a TTY. # Consider the messages possibly missed if not a TTY.
Utils::Analytics.messages_displayed! if $stdout.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"
# Consider the message possibly missed if not a TTY.
Settings.write "influxanalyticsmessage", true if $stdout.tty?
end
end end
def donation_message def donation_message

View File

@ -108,10 +108,14 @@ options: options)
report_influx_event(:build_error, package_name: formula.name, tap_name: tap.name, options: options) report_influx_event(:build_error, package_name: formula.name, tap_name: tap.name, options: options)
end end
def influx_message_displayed?
config_true?(:influxanalyticsmessage)
end
def messages_displayed? def messages_displayed?
config_true?(:analyticsmessage) && config_true?(:analyticsmessage) &&
config_true?(:caskanalyticsmessage) && config_true?(:caskanalyticsmessage) &&
config_true?(:influxanalyticsmessage) influx_message_displayed?
end end
def disabled? def disabled?