diff options
| author | Mike McQuaid | 2017-06-07 16:34:54 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2017-06-07 16:34:54 +0100 |
| commit | 5367f1b408bf3077044bd8f6aab5a8db7647c493 (patch) | |
| tree | aaf61d7d8e32c9758c7c9e79a20c380dd7ae3769 | |
| parent | cfc40196f22fd07cf62a6f51ee22915485bb4c09 (diff) | |
| download | brew-5367f1b408bf3077044bd8f6aab5a8db7647c493.tar.bz2 | |
analytics: remove unused analytics.
We didn't end up using the `screenview` and `exception` analytics as
much as expected so let's remove them and focus on stuff that's
formula-specific.
| -rw-r--r-- | Library/Homebrew/brew.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/brew.sh | 1 | ||||
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 7 | ||||
| -rw-r--r-- | Library/Homebrew/utils/analytics.rb | 21 | ||||
| -rw-r--r-- | Library/Homebrew/utils/analytics.sh | 53 | ||||
| -rw-r--r-- | docs/Analytics.md | 4 |
6 files changed, 9 insertions, 82 deletions
diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 7222f7e87..22c60f207 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -134,17 +134,15 @@ rescue Interrupt $stderr.puts # seemingly a newline is typical exit 130 rescue BuildError => e - Utils::Analytics.report_exception(e) + Utils::Analytics.report_build_error(e) e.dump exit 1 rescue RuntimeError, SystemCallError => e - Utils::Analytics.report_exception(e) raise if e.message.empty? onoe e $stderr.puts e.backtrace if ARGV.debug? exit 1 rescue MethodDeprecatedError => e - Utils::Analytics.report_exception(e) onoe e if e.issues_url $stderr.puts "If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):" @@ -152,7 +150,6 @@ rescue MethodDeprecatedError => e end exit 1 rescue Exception => e - Utils::Analytics.report_exception(e) onoe e if internal_cmd && defined?(OS::ISSUES_URL) $stderr.puts "#{Tty.bold}Please report this bug:#{Tty.reset}" diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index b76280099..97c3b7f86 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -278,7 +278,6 @@ fi # shellcheck source=/dev/null source "$HOMEBREW_LIBRARY/Homebrew/utils/analytics.sh" setup-analytics -report-analytics-screenview-command # Let user know we're still updating Homebrew if brew update --preinstall # exceeds 3 seconds. diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index fa3096542..3f85b2c17 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -271,14 +271,11 @@ class FormulaInstaller oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options.join " "}" if show_header? if formula.tap && !formula.tap.private? - category = "install" action = ([formula.full_name] + options).join(" ") - Utils::Analytics.report_event(category, action) + Utils::Analytics.report_event("install", action) if installed_on_request - category = "install_on_request" - action = ([formula.full_name] + options).join(" ") - Utils::Analytics.report_event(category, action) + Utils::Analytics.report_event("install_on_request", action) end end diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 7dd54d3f1..8c69a2980 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -61,22 +61,11 @@ module Utils ev: value) end - def report_exception(exception, options = {}) - if exception.is_a?(BuildError) && - exception.formula.tap && - exception.formula.tap.installed? && - !exception.formula.tap.private? - report_event("BuildError", exception.formula.full_name) - end - - fatal = options.fetch(:fatal, true) ? "1" : "0" - report(:exception, - exd: exception.class.name, - exf: fatal) - end - - def report_screenview(screen_name) - report(:screenview, cd: screen_name) + def report_build_error(exception) + return unless exception.formula.tap + return unless exception.formula.tap.installed? + return if exception.formula.tap.private? + report_event("BuildError", exception.formula.full_name) end end end diff --git a/Library/Homebrew/utils/analytics.sh b/Library/Homebrew/utils/analytics.sh index 8d5cf2ff7..00527fd9f 100644 --- a/Library/Homebrew/utils/analytics.sh +++ b/Library/Homebrew/utils/analytics.sh @@ -66,56 +66,3 @@ setup-analytics() { export HOMEBREW_ANALYTICS_ID export HOMEBREW_ANALYTICS_USER_UUID } - -report-analytics-screenview-command() { - [[ -n "$HOMEBREW_NO_ANALYTICS" || -n "$HOMEBREW_NO_ANALYTICS_THIS_RUN" ]] && return - - # Don't report commands that are invoked as part of other commands. - [[ "$HOMEBREW_COMMAND_DEPTH" != 1 ]] && return - - # Don't report non-official commands. - if ! [[ "$HOMEBREW_COMMAND" = "bundle" || - "$HOMEBREW_COMMAND" = "services" || - -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.rb" || - -f "$HOMEBREW_LIBRARY/Homebrew/cmd/$HOMEBREW_COMMAND.sh" || - -f "$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.rb" || - -f "$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh" ]] - then - return - fi - - # Don't report commands used mostly by our scripts and not users. - case "$HOMEBREW_COMMAND" in - --prefix|analytics|command|commands) - return - ;; - esac - - local args=( - --max-time 3 - --user-agent "$HOMEBREW_USER_AGENT_CURL" - --data v=1 - --data aip=1 - --data t=screenview - --data tid="$HOMEBREW_ANALYTICS_ID" - --data cid="$HOMEBREW_ANALYTICS_USER_UUID" - --data an="$HOMEBREW_PRODUCT" - --data av="$HOMEBREW_VERSION" - --data cd="$HOMEBREW_COMMAND" - ) - - # Send analytics. Don't send or store any personally identifiable information. - # http://docs.brew.sh/Analytics.html - # https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#screenView - # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters - if [[ -z "$HOMEBREW_ANALYTICS_DEBUG" ]] - then - "$HOMEBREW_CURL" https://www.google-analytics.com/collect \ - "${args[@]}" \ - --silent --output /dev/null &>/dev/null & disown - else - local url="https://www.google-analytics.com/debug/collect" - echo "$HOMEBREW_CURL $url ${args[*]}" - "$HOMEBREW_CURL" "$url" "${args[@]}" - fi -} diff --git a/docs/Analytics.md b/docs/Analytics.md index 69ab0b58f..15fa6fc93 100644 --- a/docs/Analytics.md +++ b/docs/Analytics.md @@ -18,14 +18,12 @@ Homebrew's analytics record some shared information for every event: - If the Google Analytics anonymous IP setting is enabled, i.e. `1` (https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#aip) - The Homebrew application name, e.g. `Homebrew` (https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#an) - The Homebrew application version, e.g. `0.9.9` (https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#av) -- The Homebrew analytics hit type, e.g. `screenview` (https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#t) +- The Homebrew analytics hit type, e.g. `event` (https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#t) Homebrew's analytics records the following different events: -- a `screenview` hit type with the official Homebrew command you have run (with arguments stripped), e.g. `brew list` (not `brew list foo` or any external commands except `bundle` and `services`) - an `event` hit type with the `install` event category and the Homebrew formula from a non-private GitHub tap you have requested to install plus any used options, e.g. `wget --with-pcre` as the action and an event label e.g. `macOS 10.12, non-/usr/local, CI` to indicate the OS version, non-standard installation location and invocation as part of CI. This allows us to identify the formulae that need fixing and where more easily. - an `event` hit type with the `BuildError` event category and the Homebrew formula that failed to install, e.g. `wget` as the action and an event label e.g. `macOS 10.12` -- an `exception` hit type with the `exception` event category and exception description of the exception name, e.g. `FormulaUnavailableError` and whether the exception was fatal e.g. `1` You can also view all the information that is sent by Homebrew's analytics by setting `HOMEBREW_ANALYTICS_DEBUG=1` in your environment. Please note this will also stop any analytics from being sent. |
