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.
This commit is contained in:
Mike McQuaid 2017-06-07 16:34:54 +01:00
parent cfc40196f2
commit 5367f1b408
6 changed files with 9 additions and 82 deletions

View File

@ -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}"

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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.