33
44echo -e " \e[34m[Info] Sourcebot version: $SOURCEBOT_VERSION \e[0m"
55
6+ # If we don't have a PostHog key, then we need to disable telemetry.
7+ if [ -z " $POSTHOG_PAPIK " ]; then
8+ echo -e " \e[33m[Warning] POSTHOG_PAPIK was not set. Setting SOURCEBOT_TELEMETRY_DISABLED.\e[0m"
9+ export SOURCEBOT_TELEMETRY_DISABLED=1
10+ fi
11+
612# Issue a info message about telemetry
713if [ ! -z " $SOURCEBOT_TELEMETRY_DISABLED " ]; then
814 echo -e " \e[34m[Info] Disabling telemetry since SOURCEBOT_TELEMETRY_DISABLED was set.\e[0m"
@@ -25,7 +31,7 @@ if [ ! -f "$FIRST_RUN_FILE" ]; then
2531 # (if telemetry is enabled)
2632 if [ -z " $SOURCEBOT_TELEMETRY_DISABLED " ]; then
2733 curl -L -s --header " Content-Type: application/json" -d ' {
28- "api_key": "' " $POSTHOG_KEY " ' ",
34+ "api_key": "' " $POSTHOG_PAPIK " ' ",
2935 "event": "install",
3036 "distinct_id": "' " $SOURCEBOT_INSTALL_ID " ' ",
3137 "properties": {
4349
4450 if [ -z " $SOURCEBOT_TELEMETRY_DISABLED " ]; then
4551 curl -L -s --header " Content-Type: application/json" -d ' {
46- "api_key": "' " $POSTHOG_KEY " ' ",
52+ "api_key": "' " $POSTHOG_PAPIK " ' ",
4753 "event": "upgrade",
4854 "distinct_id": "' " $SOURCEBOT_INSTALL_ID " ' ",
4955 "properties": {
@@ -83,12 +89,16 @@ echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m"
8389 export NEXT_PUBLIC_SOURCEBOT_VERSION=" $SOURCEBOT_VERSION "
8490 fi
8591
92+ # Always infer NEXT_PUBLIC_POSTHOG_PAPIK
93+ export NEXT_PUBLIC_POSTHOG_PAPIK=" $POSTHOG_PAPIK "
94+
8695 # Iterate over all .js files in .next & public, making substitutions for the `BAKED_` sentinal values
8796 # with their actual desired runtime value.
8897 find /app/packages/web/public /app/packages/web/.next -type f -name " *.js" |
8998 while read file; do
9099 sed -i " s|BAKED_NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED|${NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED} |g" " $file "
91100 sed -i " s|BAKED_NEXT_PUBLIC_SOURCEBOT_VERSION|${NEXT_PUBLIC_SOURCEBOT_VERSION} |g" " $file "
101+ sed -i " s|BAKED_NEXT_PUBLIC_POSTHOG_PAPIK|${NEXT_PUBLIC_POSTHOG_PAPIK} |g" " $file "
92102 done
93103}
94104
0 commit comments