diff --git a/core/cli/main.py b/core/cli/main.py index 4622731e..fe31ea8b 100644 --- a/core/cli/main.py +++ b/core/cli/main.py @@ -5,8 +5,6 @@ import sys from argparse import Namespace from asyncio import run -import sentry_sdk - from core.agents.orchestrator import Orchestrator from core.cli.helpers import delete_project, init, list_projects, list_projects_json, load_project, show_config from core.config import LLMProvider, get_config @@ -24,6 +22,12 @@ log = get_logger(__name__) telemetry_sent = False +try: + import sentry_sdk + + SENTRY_ENABLED = True +except ImportError: + SENTRY_ENABLED = False async def cleanup(ui: UIBase): @@ -280,22 +284,24 @@ async def async_main( return success telemetry.set("user_contact", args.email) - sentry_sdk.set_user( - { - # TODO add user id - # "id": args.user_id or "CLI only", - "email": args.email or "CLI only", - } - ) - sentry_sdk.set_context( - "pythagora-data", - { - "extension-version": args.extension_version or "CLI only", - "core-version": get_version(), - # TODO get environment from the extension - # "environment": args.environment, - }, - ) + if SENTRY_ENABLED: + sentry_sdk.set_user( + { + # TODO add user id + # "id": args.user_id or "CLI only", + "email": args.email or "CLI only", + } + ) + sentry_sdk.set_context( + "pythagora-data", + { + "extension-version": args.extension_version or "CLI only", + "core-version": get_version(), + # TODO get environment from the extension + # "environment": args.environment, + }, + ) + if args.extension_version: telemetry.set("is_extension", True) telemetry.set("extension_version", args.extension_version) diff --git a/main.py b/main.py index 79e36e88..e10d8993 100644 --- a/main.py +++ b/main.py @@ -2,15 +2,18 @@ import os.path import sys -import sentry_sdk +try: + import sentry_sdk -sentry_sdk.init( - dsn="https://4101633bc5560bae67d6eab013ba9686@o4508731634221056.ingest.us.sentry.io/4508732401909760", - send_default_pii=True, - traces_sample_rate=1.0, -) + sentry_sdk.init( + dsn="https://4101633bc5560bae67d6eab013ba9686@o4508731634221056.ingest.us.sentry.io/4508732401909760", + send_default_pii=True, + traces_sample_rate=1.0, + ) -sentry_sdk.profiler.start_profiler() + sentry_sdk.profiler.start_profiler() +except ImportError: + SENTRY_ENABLED = False try: from core.cli.main import run_pythagora