analytics: remove UUID.

We don't use this at all with InfluxDB and don't need it any more for GA
so let's just remove it.
This commit is contained in:
Mike McQuaid 2023-02-20 09:05:15 +00:00
parent a222a5bbc8
commit 57844530a9
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
7 changed files with 29 additions and 67 deletions

View File

@ -20,9 +20,6 @@ module Homebrew
`brew analytics` (`on`|`off`): `brew analytics` (`on`|`off`):
Turn Homebrew's analytics on or off respectively. Turn Homebrew's analytics on or off respectively.
`brew analytics regenerate-uuid`:
Regenerate the UUID used for Homebrew's Google Analytics (not InfluxDB).
EOS EOS
named_args %w[state on off regenerate-uuid], max: 1 named_args %w[state on off regenerate-uuid], max: 1
@ -36,20 +33,20 @@ module Homebrew
when nil, "state" when nil, "state"
if Utils::Analytics.disabled? if Utils::Analytics.disabled?
puts "Analytics are disabled." puts "Analytics are disabled."
elsif Homebrew::EnvConfig.no_google_analytics?
puts "InfluxDB analytics are enabled."
puts "Google Analytics are disabled."
else else
puts "Analytics are enabled." puts "Analytics are enabled."
if Homebrew::EnvConfig.no_google_analytics?
puts "Google Analytics are disabled."
elsif Utils::Analytics.uuid.present?
puts "UUID: #{Utils::Analytics.uuid}"
end
end end
when "on" when "on"
Utils::Analytics.enable! Utils::Analytics.enable!
when "off" when "off"
Utils::Analytics.disable! Utils::Analytics.disable!
when "regenerate-uuid" when "regenerate-uuid"
Utils::Analytics.regenerate_uuid! Utils::Analytics.delete_uuid!
opoo "Homebrew no longer uses an analytics UUID so this has been deleted!"
puts "brew analytics regenerate-uuid is no longer necessary."
else else
raise UsageError, "unknown subcommand: #{args.named.first}" raise UsageError, "unknown subcommand: #{args.named.first}"
end end

View File

@ -36,7 +36,7 @@ module Utils
--data aip=1 --data aip=1
--data t=#{type} --data t=#{type}
--data tid=#{analytics_id} --data tid=#{analytics_id}
--data cid=#{ENV.fetch("HOMEBREW_ANALYTICS_USER_UUID")} --data uid=n0thxg00gl3
--data an=#{HOMEBREW_PRODUCT} --data an=#{HOMEBREW_PRODUCT}
--data av=#{HOMEBREW_VERSION} --data av=#{HOMEBREW_VERSION}
] ]
@ -202,10 +202,6 @@ module Utils
ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"].present? ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"].present?
end end
def uuid
Homebrew::Settings.read :analyticsuuid
end
def messages_displayed! def messages_displayed!
Homebrew::Settings.write :analyticsmessage, true Homebrew::Settings.write :analyticsmessage, true
Homebrew::Settings.write :caskanalyticsmessage, true Homebrew::Settings.write :caskanalyticsmessage, true
@ -213,16 +209,16 @@ module Utils
def enable! def enable!
Homebrew::Settings.write :analyticsdisabled, false Homebrew::Settings.write :analyticsdisabled, false
delete_uuid!
messages_displayed! messages_displayed!
end end
def disable! def disable!
Homebrew::Settings.write :analyticsdisabled, true Homebrew::Settings.write :analyticsdisabled, true
regenerate_uuid! delete_uuid!
end end
def regenerate_uuid! def delete_uuid!
# it will be regenerated in next run unless disabled.
Homebrew::Settings.delete :analyticsuuid Homebrew::Settings.delete :analyticsuuid
end end

View File

@ -1,28 +1,23 @@
# Migrate analytics UUID to its new home in Homebrew repo's git config and # Setup analytics and delete old analytics UUIDs.
# remove the legacy UUID file if detected.
# HOMEBREW_LINUX, HOMEBREW_REPOSITORY is set by bin/brew # HOMEBREW_LINUX, HOMEBREW_REPOSITORY is set by bin/brew
# HOMEBREW_NO_ANALYTICS is from the user environment. # HOMEBREW_NO_ANALYTICS is from the user environment.
# shellcheck disable=SC2154 # shellcheck disable=SC2154
migrate-legacy-uuid-file() {
local legacy_uuid_file analytics_uuid
legacy_uuid_file="${HOME}/.homebrew_analytics_user_uuid"
if [[ -f "${legacy_uuid_file}" ]]
then
analytics_uuid="$(cat "${legacy_uuid_file}")"
if [[ -n "${analytics_uuid}" ]]
then
git config --file="${HOMEBREW_REPOSITORY}/.git/config" --replace-all homebrew.analyticsuuid "${analytics_uuid}" 2>/dev/null
fi
rm -f "${legacy_uuid_file}"
fi
}
setup-analytics() { setup-analytics() {
local git_config_file="${HOMEBREW_REPOSITORY}/.git/config" local git_config_file="${HOMEBREW_REPOSITORY}/.git/config"
migrate-legacy-uuid-file local legacy_uuid_file="${HOME}/.homebrew_analytics_user_uuid"
if [[ -f "${legacy_uuid_file}" ]]
then
rm -f "${legacy_uuid_file}"
fi
local user_uuid
user_uuid="$(git config --file="${git_config_file}" --get homebrew.analyticsuuid 2>/dev/null)"
if [[ -n "${user_uuid}" ]]
then
git config --file="${git_config_file}" --unset-all homebrew.analyticsuuid 2>/dev/null
fi
if [[ -n "${HOMEBREW_NO_ANALYTICS}" ]] if [[ -n "${HOMEBREW_NO_ANALYTICS}" ]]
then then
@ -39,28 +34,6 @@ setup-analytics() {
return return
fi fi
HOMEBREW_ANALYTICS_USER_UUID="$(git config --file="${git_config_file}" --get homebrew.analyticsuuid 2>/dev/null)"
if [[ -z "${HOMEBREW_ANALYTICS_USER_UUID}" ]]
then
if [[ -x /usr/bin/uuidgen ]]
then
HOMEBREW_ANALYTICS_USER_UUID="$(/usr/bin/uuidgen)"
elif [[ -r /proc/sys/kernel/random/uuid ]]
then
HOMEBREW_ANALYTICS_USER_UUID="$(tr a-f A-F </proc/sys/kernel/random/uuid)"
else
HOMEBREW_ANALYTICS_USER_UUID="$(uuidgen)"
fi
if [[ -z "${HOMEBREW_ANALYTICS_USER_UUID}" ]]
then
# Avoid sending bogus analytics if no UUID could be generated.
export HOMEBREW_NO_ANALYTICS_THIS_RUN="1"
return
fi
git config --file="${git_config_file}" --replace-all homebrew.analyticsuuid "${HOMEBREW_ANALYTICS_USER_UUID}" 2>/dev/null
fi
if [[ -n "${HOMEBREW_LINUX}" ]] if [[ -n "${HOMEBREW_LINUX}" ]]
then then
# For Homebrew on Linux's analytics. # For Homebrew on Linux's analytics.

View File

@ -1,6 +1,6 @@
# Bash completion script for brew(1) # Bash completion script for brew(1)
if [[ -n ${POSIXLY_CORRECT} ]] || shopt -oq posix if test -v POSIXLY_CORRECT || test -o posix
then then
echo "Homebrew Bash completions do not work in POSIX mode" 1>&2 echo "Homebrew Bash completions do not work in POSIX mode" 1>&2
return return

View File

@ -32,12 +32,15 @@ For analytics sent to Google Analytics, which is in the process of being phased
- The Homebrew user agent, e.g. `Homebrew/3.3.0 (Macintosh; Intel Mac OS X 10.15.6) curl/7.64.1`. - The Homebrew user agent, e.g. `Homebrew/3.3.0 (Macintosh; Intel Mac OS X 10.15.6) curl/7.64.1`.
- The [Google Analytics version](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#v), i.e. `1`. - The [Google Analytics version](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#v), i.e. `1`.
- The Homebrew [analytics tracking ID](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#tid), e.g. `UA-75654628-1`. - The Homebrew [analytics tracking ID](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#tid), i.e. `UA-76679469-1` on macOS and `UA-76492262-1` on Linux. This value is constant and is the same for all users.
- A Homebrew [analytics user ID](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid), e.g. `1BAB65CC-FE7F-4D8C-AB45-B7DB5A6BA9CB`. This is generated by `uuidgen` and stored in the repository-specific Git configuration variable `homebrew.analyticsuuid` within `$(brew --repository)/.git/config`. This does not allow us to track individual users, but does enable us to accurately measure user counts versus event counts. The ID is specific to the Homebrew package manager, and does not permit Homebrew maintainers to e.g. track you across websites you visit. It is only used with Google Analytics.
- Whether the [Google Analytics anonymous IP setting](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#aip) is enabled, i.e. `1`. - Whether the [Google Analytics anonymous IP setting](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#aip) is enabled, i.e. `1`.
- The Homebrew [application name](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#an), e.g. `Homebrew`. - The Homebrew [application name](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#an), e.g. `Homebrew`.
- The Homebrew [analytics hit type](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#t), e.g. `event`. - The Homebrew [analytics hit type](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#t), e.g. `event`.
We previously recorded but have now removed:
- A Homebrew [analytics user ID](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid), e.g. `1BAB65CC-FE7F-4D8C-AB45-B7DB5A6BA9CB`. This was generated by `uuidgen` and stored in the repository-specific Git configuration variable `homebrew.analyticsuuid` within `$(brew --repository)/.git/config`. This did not allow us to track individual users, but does enable us to accurately measure user counts versus event counts. The ID was specific to the Homebrew package manager, and did not permit Homebrew maintainers to e.g. track you across websites you visit. It was only used with Google Analytics.
Homebrew's analytics records the following different events: Homebrew's analytics records the following different events:
- The `install` event category and the Homebrew formula from a non-private GitHub tap you install plus any used options (e.g. `wget --HEAD`) as the action. This allows us to identify which formulae where work should be prioritised, as well as how to handle possible deprecation or removal of any. - The `install` event category and the Homebrew formula from a non-private GitHub tap you install plus any used options (e.g. `wget --HEAD`) as the action. This allows us to identify which formulae where work should be prioritised, as well as how to handle possible deprecation or removal of any.

View File

@ -79,9 +79,6 @@ Read more at <https://docs.brew.sh/Analytics>.
`brew analytics` (`on`|`off`) `brew analytics` (`on`|`off`)
<br>Turn Homebrew's analytics on or off respectively. <br>Turn Homebrew's analytics on or off respectively.
`brew analytics regenerate-uuid`
<br>Regenerate the UUID used for Homebrew's Google Analytics (not InfluxDB).
### `autoremove` [`--dry-run`] ### `autoremove` [`--dry-run`]
Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed. Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed.

View File

@ -92,10 +92,6 @@ Control Homebrew\'s anonymous aggregate user behaviour analytics\. Read more at
\fBbrew analytics\fR (\fBon\fR|\fBoff\fR) \fBbrew analytics\fR (\fBon\fR|\fBoff\fR)
Turn Homebrew\'s analytics on or off respectively\. Turn Homebrew\'s analytics on or off respectively\.
. .
.P
\fBbrew analytics regenerate\-uuid\fR
Regenerate the UUID used for Homebrew\'s Google Analytics (not InfluxDB)\.
.
.SS "\fBautoremove\fR [\fB\-\-dry\-run\fR]" .SS "\fBautoremove\fR [\fB\-\-dry\-run\fR]"
Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed\. Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed\.
. .