From 213ef9d325b036f187c8d0d2dc452557dc2ced84 Mon Sep 17 00:00:00 2001 From: Kerem Yilmaz Date: Wed, 6 Mar 2024 15:44:58 -0800 Subject: [PATCH] Update setup.sh to ask for openai key and email (#38) --- .env.example | 3 +++ README.md | 4 ---- scripts/tracking.py | 6 ++++-- setup.sh | 26 ++++++++++++++++++++++++++ skyvern/config.py | 1 + 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 2441bcd9..dd6f9bac 100644 --- a/.env.example +++ b/.env.example @@ -20,3 +20,6 @@ LOG_LEVEL=INFO DATABASE_STRING="postgresql+psycopg://skyvern@localhost/skyvern" # Port to run the agent on PORT=8000 + +# Distinct analytics ID +ANALYTICS_ID="anonymous" \ No newline at end of file diff --git a/README.md b/README.md index f8300315..b298d334 100644 --- a/README.md +++ b/README.md @@ -81,10 +81,6 @@ Note: Our setup script does these two for you, but they are here for reference. ```bash ./setup.sh ``` -1. Create the `.env` file by copying the `.env.example` file and fill in the necessary environment variables (such as your OpenAI API key, etc.) - ```bash - cp .env.example .env - ``` 1. Start the server ```bash ./run_skyvern.sh diff --git a/scripts/tracking.py b/scripts/tracking.py index 3d900019..ae0a11d1 100644 --- a/scripts/tracking.py +++ b/scripts/tracking.py @@ -43,9 +43,11 @@ def capture( if not SettingsManager.get_settings().SKYVERN_TELEMETRY: return + distinct_id = SettingsManager.get_settings().ANALYTICS_ID + payload: dict[str, Any] = data or {} try: - posthog.capture(distinct_id=DISTINCT_ID, event=event, properties=payload) + posthog.capture(distinct_id=distinct_id, event=event, properties=payload) except Exception as e: payload.update( { @@ -53,7 +55,7 @@ def capture( } ) posthog.capture( - distinct_id=DISTINCT_ID, + distinct_id=distinct_id, event="failure", properties=payload, ) diff --git a/setup.sh b/setup.sh index d42be715..a23a05a2 100755 --- a/setup.sh +++ b/setup.sh @@ -20,6 +20,31 @@ for cmd in poetry python3.11; do fi done +# Function to initialize .env file +initialize_env_file() { + if [ -f ".env" ]; then + echo ".env file already exists, skipping initialization." + return + fi + + echo "Initializing .env file..." + cp .env.example .env + + # Ask for OpenAI API key + read -p "Please enter your OpenAI API key for GPT4V (this will be stored only in your local .env file): " openai_api_key + awk -v key="$openai_api_key" '{gsub(/OPENAI_API_KEYS=\["abc","def","ghi"\]/, "OPENAI_API_KEYS=[\"" key "\"]"); print}' .env > .env.tmp && mv .env.tmp .env + + + # Ask for email or generate UUID + read -p "Please enter your email for analytics tracking (press enter to skip): " analytics_id + if [ -z "$analytics_id" ]; then + analytics_id=$(uuidgen) + fi + awk -v id="$analytics_id" '{gsub(/ANALYTICS_ID="anonymous"/, "ANALYTICS_ID=\"" id "\""); print}' .env > .env.tmp && mv .env.tmp .env + + echo ".env file has been initialized." +} + # Function to remove Poetry environment remove_poetry_env() { local env_path @@ -102,6 +127,7 @@ create_organization() { # Main function main() { + initialize_env_file remove_poetry_env install_dependencies setup_postgresql diff --git a/skyvern/config.py b/skyvern/config.py index ad3fed10..3be40bf2 100644 --- a/skyvern/config.py +++ b/skyvern/config.py @@ -41,6 +41,7 @@ class Settings(BaseSettings): ARTIFACT_STORAGE_PATH: str = f"{SKYVERN_DIR}/artifacts" SKYVERN_TELEMETRY: bool = True + ANALYTICS_ID: str = "anonymous" def is_cloud_environment(self) -> bool: """