feat: 更新脚本以及添加安装统计

This commit is contained in:
neo 2023-07-22 17:33:00 +08:00
parent 48b2419c66
commit 244fe0967a

View File

@ -900,28 +900,28 @@ EOABORT
)"
fi
USABLE_GIT="$(command -v git)"
if [[ -z "${USABLE_GIT}" ]]
USABLE_GIT=/usr/bin/git
if [[ -n "${HOMEBREW_ON_LINUX-}" ]]
then
abort "$(
cat <<EOABORT
You must install Git before installing Homebrew. See:
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
EOABORT
)"
elif [[ -n "${HOMEBREW_ON_LINUX-}" ]]
then
suitable_git="$(find_tool git)"
if [[ -z "${suitable_git}" ]]
USABLE_GIT="$(find_tool git)"
if [[ -z "$(command -v git)" ]]
then
abort "$(
cat <<EOABORT
The version of Git that was found does not satisfy requirements for Homebrew.
Please install Git ${REQUIRED_GIT_VERSION} or newer and add it to your PATH.
You must install Git before installing Homebrew. See:
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
EOABORT
)"
fi
if [[ -z "${USABLE_GIT}" ]]
then
abort "$(
cat <<EOABORT
The version of Git that was found does not satisfy requirements for Homebrew.
Please install Git ${REQUIRED_GIT_VERSION} or newer and add it to your PATH.
EOABORT
)"
fi
USABLE_GIT="${suitable_git}"
if [[ "${USABLE_GIT}" != /usr/bin/git ]]
then
export HOMEBREW_GIT_PATH="${USABLE_GIT}"
@ -962,6 +962,44 @@ then
export HOMEBREW_DEVELOPER=1
fi
GA_MEASUREMENT_ID="G-QHRH8YZXHT"
GA_SECRET_KEY="aaVeaADWRTSl9fnarX6xhA"
url="https://www.google-analytics.com/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_SECRET_KEY}"
HOMEBREW_SYSTEM="$(uname -s)"
case "$HOMEBREW_SYSTEM" in
Darwin) HOMEBREW_OSX="1";;
Linux) HOMEBREW_LINUX="1";;
esac
if [[ -n "${HOMEBREW_OSX-}" ]]
then
HOMEBREW_PROCESSOR="$(uname -p)"
HOMEBREW_PRODUCT="Homebrew"
HOMEBREW_SYSTEM="Macintosh"
# This is i386 even on x86_64 machines
[[ "$HOMEBREW_PROCESSOR" = "i386" ]] && HOMEBREW_PROCESSOR="Intel"
HOMEBREW_OS_VERSION="Mac OS X $macos_version"
else
HOMEBREW_PROCESSOR="$(uname -m)"
HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew"
[[ -n "${HOMEBREW_LINUX-}" ]] && HOMEBREW_OS_VERSION="$(lsb_release -sd 2>/dev/null)"
: "${HOMEBREW_OS_VERSION:=$(uname -r)}"
fi
HOMEBREW_USER_AGENT="$HOMEBREW_PRODUCT ($HOMEBREW_SYSTEM; $HOMEBREW_PROCESSOR $HOMEBREW_OS_VERSION)"
client_id="$RANDOM"
report_install_to_ga4() {
payload='{"client_id":"'$client_id'","events":[{"name":"'$1'","params":{"user_agent":"'$HOMEBREW_USER_AGENT'"}}]}'
curl -s -X POST "$url" -d "$payload"
}
report_install_to_ga4 'brew_install_start'
ohai "Downloading and installing Homebrew..."
(
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
@ -1194,3 +1232,5 @@ cat <<EOS
🌟 点赞:${tty_underline}https://github.com/ineo6/homebrew-install${tty_reset}
🌟 点赞:${tty_underline}https://gitee.com/ineo6/homebrew-install${tty_reset}
EOS
report_install_to_ga4 'brew_install_finish'