analytics: don't report commands run by Homebrew

Fixes #788.
This commit is contained in:
Alyssa Ross 2016-10-01 15:18:09 +01:00
parent cc59e624b0
commit e0d39cc3ef
2 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,10 @@ then
HOMEBREW_VERSION=">1.0.0 (no git repository)" HOMEBREW_VERSION=">1.0.0 (no git repository)"
fi fi
# A depth of 1 means this command was directly invoked by a user.
# Higher depths mean this command was invoked by another Homebrew command.
export HOMEBREW_COMMAND_DEPTH=$((HOMEBREW_COMMAND_DEPTH + 1))
onoe() { onoe() {
if [[ -t 2 ]] # check whether stderr is a tty. if [[ -t 2 ]] # check whether stderr is a tty.
then then

View File

@ -70,6 +70,9 @@ setup-analytics() {
report-analytics-screenview-command() { report-analytics-screenview-command() {
[[ -n "$HOMEBREW_NO_ANALYTICS" || -n "$HOMEBREW_NO_ANALYTICS_THIS_RUN" ]] && return [[ -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. # Don't report non-official commands.
if ! [[ "$HOMEBREW_COMMAND" = "bundle" || if ! [[ "$HOMEBREW_COMMAND" = "bundle" ||
"$HOMEBREW_COMMAND" = "services" || "$HOMEBREW_COMMAND" = "services" ||