mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Analytics: Separate user-supplied and internal-use DISABLE_ANALYTICS (#155)
This prevents `brew` self-calls from interacting with the stickiness of HOMEBREW_NO_ANALYTICS being persisted to the brew repo and accidentally disabling analytics permanently when it should have been for just one run, while restoring the stickiness of an explicit user-supplied HOMEBREW_NO_ANALYTICS.
This commit is contained in:
parent
7aaaf9d8db
commit
05efd70dc3
@ -3,7 +3,7 @@ require "fileutils"
|
||||
module Homebrew
|
||||
def tests
|
||||
(HOMEBREW_LIBRARY/"Homebrew/test").cd do
|
||||
ENV["HOMEBREW_NO_ANALYTICS"] = "1"
|
||||
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
|
||||
ENV["TESTOPTS"] = "-v" if ARGV.verbose?
|
||||
ENV["HOMEBREW_NO_COMPAT"] = "1" if ARGV.include? "--no-compat"
|
||||
if ARGV.include? "--coverage"
|
||||
|
@ -18,7 +18,7 @@ module Homebrew
|
||||
analytics_disabled = \
|
||||
Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chuzzle
|
||||
if analytics_message_displayed != "true" && analytics_disabled != "true"
|
||||
ENV["HOMEBREW_NO_ANALYTICS"] = "1"
|
||||
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
|
||||
ohai "Homebrew has enabled anonymous aggregate user behaviour analytics"
|
||||
puts "Read the analytics documentation (and how to opt-out) here:"
|
||||
puts " https://git.io/brew-analytics"
|
||||
|
@ -8,7 +8,7 @@ def analytics_label
|
||||
end
|
||||
|
||||
def report_analytics(type, metadata = {})
|
||||
return if ENV["HOMEBREW_NO_ANALYTICS"]
|
||||
return if ENV["HOMEBREW_NO_ANALYTICS"] || ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"]
|
||||
|
||||
args = %W[
|
||||
--max-time 3
|
||||
|
@ -3,12 +3,19 @@ setup-analytics() {
|
||||
# recreated with no adverse effect (beyond our user counts being inflated).
|
||||
HOMEBREW_ANALYTICS_USER_UUID_FILE="$HOME/.homebrew_analytics_user_uuid"
|
||||
|
||||
if [[ -n "$HOMEBREW_NO_ANALYTICS" ||
|
||||
"$(git config --file="$HOMEBREW_REPOSITORY/.git/config" --get homebrew.analyticsmessage)" != "true" ||
|
||||
# Make disabling anlytics sticky
|
||||
if [[ -n "$HOMEBREW_NO_ANALYTICS" ]]
|
||||
then
|
||||
git config --file="$HOMEBREW_REPOSITORY/.git/config" --replace-all homebrew.analyticsdisabled true
|
||||
# Internal variable for brew's use, to differentiate from user-supplied setting
|
||||
export HOMEBREW_NO_ANALYTICS_THIS_RUN="1"
|
||||
fi
|
||||
|
||||
if [[ "$(git config --file="$HOMEBREW_REPOSITORY/.git/config" --get homebrew.analyticsmessage)" != "true" ||
|
||||
"$(git config --file="$HOMEBREW_REPOSITORY/.git/config" --get homebrew.analyticsdisabled)" = "true" ]]
|
||||
then
|
||||
[[ -f "$HOMEBREW_ANALYTICS_USER_UUID_FILE" ]] && rm -f "$HOMEBREW_ANALYTICS_USER_UUID_FILE"
|
||||
export HOMEBREW_NO_ANALYTICS="1"
|
||||
export HOMEBREW_NO_ANALYTICS_THIS_RUN="1"
|
||||
return
|
||||
fi
|
||||
|
||||
@ -34,7 +41,7 @@ setup-analytics() {
|
||||
}
|
||||
|
||||
report-analytics-screenview-command() {
|
||||
[[ -n "$HOMEBREW_NO_ANALYTICS" ]] && return
|
||||
[[ -n "$HOMEBREW_NO_ANALYTICS" || -n "$HOMEBREW_NO_ANALYTICS_THIS_RUN" ]] && return
|
||||
|
||||
# Don't report non-official commands.
|
||||
if ! [[ "$HOMEBREW_COMMAND" = "bundle" ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user