diff --git a/Library/Homebrew/cmd/analytics.rb b/Library/Homebrew/cmd/analytics.rb index 499f03a43f..984ad24db1 100644 --- a/Library/Homebrew/cmd/analytics.rb +++ b/Library/Homebrew/cmd/analytics.rb @@ -20,9 +20,6 @@ module Homebrew `brew analytics` (`on`|`off`): Turn Homebrew's analytics on or off respectively. - - `brew analytics regenerate-uuid`: - Regenerate the UUID used for Homebrew's Google Analytics (not InfluxDB). EOS named_args %w[state on off regenerate-uuid], max: 1 @@ -36,20 +33,20 @@ module Homebrew when nil, "state" if Utils::Analytics.disabled? puts "Analytics are disabled." + elsif Homebrew::EnvConfig.no_google_analytics? + puts "InfluxDB analytics are enabled." + puts "Google Analytics are disabled." else 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 when "on" Utils::Analytics.enable! when "off" Utils::Analytics.disable! 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 raise UsageError, "unknown subcommand: #{args.named.first}" end diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 79e9835511..a521ddbdf6 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -36,7 +36,7 @@ module Utils --data aip=1 --data t=#{type} --data tid=#{analytics_id} - --data cid=#{ENV.fetch("HOMEBREW_ANALYTICS_USER_UUID")} + --data uid=n0thxg00gl3 --data an=#{HOMEBREW_PRODUCT} --data av=#{HOMEBREW_VERSION} ] @@ -202,10 +202,6 @@ module Utils ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"].present? end - def uuid - Homebrew::Settings.read :analyticsuuid - end - def messages_displayed! Homebrew::Settings.write :analyticsmessage, true Homebrew::Settings.write :caskanalyticsmessage, true @@ -213,16 +209,16 @@ module Utils def enable! Homebrew::Settings.write :analyticsdisabled, false + delete_uuid! messages_displayed! end def disable! Homebrew::Settings.write :analyticsdisabled, true - regenerate_uuid! + delete_uuid! end - def regenerate_uuid! - # it will be regenerated in next run unless disabled. + def delete_uuid! Homebrew::Settings.delete :analyticsuuid end diff --git a/Library/Homebrew/utils/analytics.sh b/Library/Homebrew/utils/analytics.sh index eb10fe8d18..e3538895a2 100644 --- a/Library/Homebrew/utils/analytics.sh +++ b/Library/Homebrew/utils/analytics.sh @@ -1,28 +1,23 @@ -# Migrate analytics UUID to its new home in Homebrew repo's git config and -# remove the legacy UUID file if detected. +# Setup analytics and delete old analytics UUIDs. # HOMEBREW_LINUX, HOMEBREW_REPOSITORY is set by bin/brew # HOMEBREW_NO_ANALYTICS is from the user environment. # 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() { 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}" ]] then @@ -39,28 +34,6 @@ setup-analytics() { return 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 /dev/null - fi - if [[ -n "${HOMEBREW_LINUX}" ]] then # For Homebrew on Linux's analytics. diff --git a/completions/bash/brew b/completions/bash/brew index 5d79136756..d7197267f9 100644 --- a/completions/bash/brew +++ b/completions/bash/brew @@ -1,6 +1,6 @@ # Bash completion script for brew(1) -if [[ -n ${POSIXLY_CORRECT} ]] || shopt -oq posix +if test -v POSIXLY_CORRECT || test -o posix then echo "Homebrew Bash completions do not work in POSIX mode" 1>&2 return diff --git a/docs/Analytics.md b/docs/Analytics.md index 89f83d6a47..09bce34741 100644 --- a/docs/Analytics.md +++ b/docs/Analytics.md @@ -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 [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`. -- 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. +- 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. - 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 [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: - 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. diff --git a/docs/Manpage.md b/docs/Manpage.md index 9ccccae78f..95e443bd60 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -79,9 +79,6 @@ Read more at . `brew analytics` (`on`|`off`)
Turn Homebrew's analytics on or off respectively. -`brew analytics regenerate-uuid` -
Regenerate the UUID used for Homebrew's Google Analytics (not InfluxDB). - ### `autoremove` [`--dry-run`] Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed. diff --git a/manpages/brew.1 b/manpages/brew.1 index 472bd723cf..c48811fe13 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -92,10 +92,6 @@ Control Homebrew\'s anonymous aggregate user behaviour analytics\. Read more at \fBbrew analytics\fR (\fBon\fR|\fBoff\fR) 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]" Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed\. .