aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-03-28 09:33:45 +0100
committerMike McQuaid2016-04-04 12:25:11 +0100
commit0b79f48aad33a0b89fd6dc07d0103040449361b5 (patch)
tree50eefcaeaed85a19e57ec241fcea2ed818fe105d /Library
parent77611bafb1dfc68e9cd59fb21163aefa53fccf2c (diff)
downloadbrew-0b79f48aad33a0b89fd6dc07d0103040449361b5.tar.bz2
Add opt-in Google Analytics.
Add the first Google Analytics usage to monitor the command names that are run by Homebrew.
Diffstat (limited to 'Library')
-rw-r--r--Library/brew.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/Library/brew.sh b/Library/brew.sh
index eb6c19a97..cbde0e7c4 100644
--- a/Library/brew.sh
+++ b/Library/brew.sh
@@ -198,6 +198,39 @@ EOS
esac
fi
+if [[ -n "$HOMEBREW_ANALYTICS" ]]
+then
+ # User UUID file. Used for Homebrew user counting. Can be deleted and
+ # recreated with no adverse effect (beyond our user counts being inflated).
+ HOMEBREW_ANALYTICS_USER_UUID_FILE="$HOME/.homebrew_analytics_user_uuid"
+ if [[ -r "$HOMEBREW_ANALYTICS_USER_UUID_FILE" ]]
+ then
+ HOMEBREW_ANALYTICS_USER_UUID="$(cat "$HOMEBREW_ANALYTICS_USER_UUID_FILE")"
+ else
+ HOMEBREW_ANALYTICS_USER_UUID="$(uuidgen)"
+ echo "$HOMEBREW_ANALYTICS_USER_UUID" > "$HOMEBREW_ANALYTICS_USER_UUID_FILE"
+ fi
+ export HOMEBREW_ANALYTICS_ID="UA-75654628-1"
+ export HOMEBREW_ANALYTICS_USER_UUID
+
+ # Send the to-be-executed command as an "App Screen View". Anonymise the IP
+ # address (aip=1) and don't send or store any personally identifiable
+ # information.
+ # https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#screenView
+ # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
+ curl https://www.google-analytics.com/collect -d v=1 \
+ --silent --max-time 3 --output /dev/null \
+ --user-agent "$HOMEBREW_USER_AGENT_CURL" \
+ -d tid="$HOMEBREW_ANALYTICS_ID" \
+ -d cid="$HOMEBREW_ANALYTICS_USER_UUID" \
+ -d aip=1 \
+ -d an=Homebrew \
+ -d av="$HOMEBREW_VERSION" \
+ -d t=screenview \
+ -d cd="$HOMEBREW_COMMAND" \
+ &
+fi
+
if [[ -n "$HOMEBREW_BASH_COMMAND" ]]
then
# source rather than executing directly to ensure the entire file is read into