diff --git a/CHANGELOG.md b/CHANGELOG.md index b64bd46b..a8a8ac58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fixed issue where we crash on startup if the install / upgrade PostHog event fails to send. ([#159](https://github.com/sourcebot-dev/sourcebot/pull/159)) + ## [2.7.0] - 2025-01-10 ### Added diff --git a/entrypoint.sh b/entrypoint.sh index 6bc3b70a..2ed5ec20 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,14 +30,16 @@ if [ ! -f "$FIRST_RUN_FILE" ]; then # If this is our first run, send a `install` event to PostHog # (if telemetry is enabled) if [ -z "$SOURCEBOT_TELEMETRY_DISABLED" ]; then - curl -L -s --header "Content-Type: application/json" -d '{ + if ! ( curl -L --output /dev/null --silent --fail --header "Content-Type: application/json" -d '{ "api_key": "'"$POSTHOG_PAPIK"'", "event": "install", "distinct_id": "'"$SOURCEBOT_INSTALL_ID"'", "properties": { "sourcebot_version": "'"$SOURCEBOT_VERSION"'" } - }' https://us.i.posthog.com/capture/ > /dev/null + }' https://us.i.posthog.com/capture/ ) then + echo -e "\e[33m[Warning] Failed to send install event.\e[0m" + fi fi else export SOURCEBOT_INSTALL_ID=$(cat "$FIRST_RUN_FILE" | jq -r '.install_id') @@ -48,7 +50,7 @@ else echo -e "\e[34m[Info] Upgraded from version $PREVIOUS_VERSION to $SOURCEBOT_VERSION\e[0m" if [ -z "$SOURCEBOT_TELEMETRY_DISABLED" ]; then - curl -L -s --header "Content-Type: application/json" -d '{ + if ! ( curl -L --output /dev/null --silent --fail --header "Content-Type: application/json" -d '{ "api_key": "'"$POSTHOG_PAPIK"'", "event": "upgrade", "distinct_id": "'"$SOURCEBOT_INSTALL_ID"'", @@ -56,7 +58,9 @@ else "from_version": "'"$PREVIOUS_VERSION"'", "to_version": "'"$SOURCEBOT_VERSION"'" } - }' https://us.i.posthog.com/capture/ > /dev/null + }' https://us.i.posthog.com/capture/ ) then + echo -e "\e[33m[Warning] Failed to send upgrade event.\e[0m" + fi fi fi fi