Skip to content

Commit a013298

Browse files
curl error handling in entrypoint.sh (#159)
1 parent 7599980 commit a013298

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- 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))
13+
1014
## [2.7.0] - 2025-01-10
1115

1216
### Added

entrypoint.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ if [ ! -f "$FIRST_RUN_FILE" ]; then
3030
# If this is our first run, send a `install` event to PostHog
3131
# (if telemetry is enabled)
3232
if [ -z "$SOURCEBOT_TELEMETRY_DISABLED" ]; then
33-
curl -L -s --header "Content-Type: application/json" -d '{
33+
if ! ( curl -L --output /dev/null --silent --fail --header "Content-Type: application/json" -d '{
3434
"api_key": "'"$POSTHOG_PAPIK"'",
3535
"event": "install",
3636
"distinct_id": "'"$SOURCEBOT_INSTALL_ID"'",
3737
"properties": {
3838
"sourcebot_version": "'"$SOURCEBOT_VERSION"'"
3939
}
40-
}' https://us.i.posthog.com/capture/ > /dev/null
40+
}' https://us.i.posthog.com/capture/ ) then
41+
echo -e "\e[33m[Warning] Failed to send install event.\e[0m"
42+
fi
4143
fi
4244
else
4345
export SOURCEBOT_INSTALL_ID=$(cat "$FIRST_RUN_FILE" | jq -r '.install_id')
@@ -48,15 +50,17 @@ else
4850
echo -e "\e[34m[Info] Upgraded from version $PREVIOUS_VERSION to $SOURCEBOT_VERSION\e[0m"
4951

5052
if [ -z "$SOURCEBOT_TELEMETRY_DISABLED" ]; then
51-
curl -L -s --header "Content-Type: application/json" -d '{
53+
if ! ( curl -L --output /dev/null --silent --fail --header "Content-Type: application/json" -d '{
5254
"api_key": "'"$POSTHOG_PAPIK"'",
5355
"event": "upgrade",
5456
"distinct_id": "'"$SOURCEBOT_INSTALL_ID"'",
5557
"properties": {
5658
"from_version": "'"$PREVIOUS_VERSION"'",
5759
"to_version": "'"$SOURCEBOT_VERSION"'"
5860
}
59-
}' https://us.i.posthog.com/capture/ > /dev/null
61+
}' https://us.i.posthog.com/capture/ ) then
62+
echo -e "\e[33m[Warning] Failed to send upgrade event.\e[0m"
63+
fi
6064
fi
6165
fi
6266
fi

0 commit comments

Comments
 (0)