mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-11 20:05:25 +00:00
Add 'install' event that is fired once on first run (#11)
This commit is contained in:
parent
fed2f75a28
commit
74b9fe5c57
3 changed files with 35 additions and 3 deletions
4
.env
4
.env
|
|
@ -1,4 +1,6 @@
|
|||
NEXT_PUBLIC_POSTHOG_KEY=phc_VFn4CkEGHRdlVyOOw8mfkoj1DKVoG6y1007EClvzAnS
|
||||
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
|
||||
NEXT_PUBLIC_POSTHOG_ASSET_HOST=https://us-assets.i.posthog.com
|
||||
NEXT_PUBLIC_POSTHOG_UI_HOST=https://us.posthog.com
|
||||
|
||||
# @note: This is also set in the Dockerfile.
|
||||
NEXT_PUBLIC_POSTHOG_KEY=phc_VFn4CkEGHRdlVyOOw8mfkoj1DKVoG6y1007EClvzAnS
|
||||
|
|
@ -35,11 +35,14 @@ ENV DATA_DIR=/data
|
|||
ENV CONFIG_PATH=$DATA_DIR/config.json
|
||||
ENV DATA_CACHE_DIR=$DATA_DIR/.sourcebot
|
||||
|
||||
# @note: This is also set in .env
|
||||
ENV NEXT_PUBLIC_POSTHOG_KEY=phc_VFn4CkEGHRdlVyOOw8mfkoj1DKVoG6y1007EClvzAnS
|
||||
|
||||
# Sourcebot collects anonymous usage data using [PostHog](https://posthog.com/). Uncomment this line to disable.
|
||||
# ENV SOURCEBOT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Configure dependencies
|
||||
RUN apk add --no-cache git ca-certificates bind-tools tini jansson wget supervisor
|
||||
RUN apk add --no-cache git ca-certificates bind-tools tini jansson wget supervisor uuidgen curl
|
||||
|
||||
# Configure zoekt
|
||||
COPY vendor/zoekt/install-ctags-alpine.sh .
|
||||
|
|
|
|||
|
|
@ -1,6 +1,33 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Issue a info message about telemetry
|
||||
if [ ! -z "$SOURCEBOT_TELEMETRY_DISABLED" ]; then
|
||||
echo -e "\e[34m[Info] Disabling telemetry since SOURCEBOT_TELEMETRY_DISABLED was set.\e[0m"
|
||||
fi
|
||||
|
||||
# Check if DATA_CACHE_DIR exists, if not create it
|
||||
if [ ! -d "$DATA_CACHE_DIR" ]; then
|
||||
mkdir -p "$DATA_CACHE_DIR"
|
||||
fi
|
||||
|
||||
# In order to detect if this is the first run, we create a `.installed` file in
|
||||
# the cache directory.
|
||||
FIRST_RUN_FILE="$DATA_CACHE_DIR/.installed"
|
||||
if [ ! -f "$FIRST_RUN_FILE" ]; then
|
||||
touch "$FIRST_RUN_FILE"
|
||||
|
||||
# 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 '{
|
||||
"api_key": "'"$NEXT_PUBLIC_POSTHOG_KEY"'",
|
||||
"event": "install",
|
||||
"distinct_id": "'"$(uuidgen)"'"
|
||||
}' https://us.i.posthog.com/capture/ > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fallback to sample config if a config does not exist
|
||||
if [ ! -f "$CONFIG_PATH" ]; then
|
||||
echo -e "\e[33m[Warning] Config file at CONFIG_PATH not found. Falling back on sample config.\e[0m"
|
||||
|
|
|
|||
Loading…
Reference in a new issue