Added very basic telemetry to installer script.

This commit is contained in:
Martin Sosic 2021-02-11 22:24:16 +01:00
parent 9489e9f247
commit 89300a9e0a

View File

@ -32,6 +32,7 @@ done
main() {
trap cleanup_temp_dir EXIT
send_telemetry > /dev/null 2>&1 &
install_based_on_os
}
@ -48,6 +49,20 @@ install_based_on_os() {
esac
}
get_os_info() {
case "$(uname)" in
"Linux")
echo "Linux"
;;
"Darwin")
echo "Darwin"
;;
*)
echo "Unknown"
;;
esac
}
# TODO: Add option to specify which release to download.
# Download a Wasp binary package and install it in $HOME_LOCAL_BIN.
@ -205,4 +220,18 @@ on_path() {
echo ":$PATH_NORMALIZED:" | grep -q ":$QUERY_NORMALIZED:"
}
send_telemetry() {
DATA='{ "api_key": "CdDd2A0jKTI2vFAsrI9JWm3MqpOcgHz1bMyogAcwsE4", "type": "capture", "event": "install-script:run", "distinct_id": "'$RANDOM`date +'%s%N'`'", "properties": { "os": "'`get_os_info`'" } }'
URL="https://app.posthog.com/capture"
HEADER="Content-Type: application/json"
if [ -z "$WASP_TELEMETRY_DISABLE" ]; then
if has_curl; then
curl -sfL -d "$DATA" --header "$HEADER" "$URL" > /dev/null 2>&1
elif has_wget; then
wget -q --post-data="$DATA" --header="$HEADER" "$URL" > /dev/null 2>&1
fi
fi
}
main