From ab5a362dafd98253036c93535fce044c5eb9ee8f Mon Sep 17 00:00:00 2001 From: bkellam Date: Tue, 14 Jan 2025 14:42:14 -0800 Subject: [PATCH 1/2] Add error handling in entrypoint.sh to catch issues when issuing upgrade / install events --- entrypoint.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 From 488bac51bb700276c79c6a91d938a741733759a8 Mon Sep 17 00:00:00 2001 From: bkellam Date: Tue, 14 Jan 2025 14:59:58 -0800 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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