From 8f98b2bcc4118f7bc9bc4f997613c86aedf8bfc5 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 22 Feb 2020 17:13:51 +0000 Subject: [PATCH] analytics: tweak behaviour. - Use separate method for `not_this_run?` so we can still set the analytics message as seen when set. - Clarify when analytics message is printed that we haven't sent any analytics yet. --- Library/Homebrew/cmd/update-report.rb | 1 + Library/Homebrew/utils/analytics.rb | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index f247e034db..e9d5370835 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -51,6 +51,7 @@ module Homebrew 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 (or will be during this `brew` run). EOS diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index c05edb3756..c225be5ac9 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -6,6 +6,7 @@ module Utils module Analytics class << self def report(type, metadata = {}) + return if not_this_run? return if disabled? args = [] @@ -77,11 +78,15 @@ module Utils end def disabled? - return true if ENV["HOMEBREW_NO_ANALYTICS"] || ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] + return true if ENV["HOMEBREW_NO_ANALYTICS"] config_true?(:analyticsdisabled) end + def not_this_run? + ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"].present? + end + def no_message_output? # Used by Homebrew/install ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"].present?