Skip to content
Snippets Groups Projects
Commit 0b79f48a authored by Mike McQuaid's avatar Mike McQuaid
Browse files

Add opt-in Google Analytics.

Add the first Google Analytics usage to monitor the command names that
are run by Homebrew.
parent 77611baf
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment