AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(agent/telemetry): Distinguish between users
Reinier van der Leerae197fc85fee
diff --git a/autogpts/autogpt/autogpt/app/agent_protocol_server.py b/autogpts/autogpt/autogpt/app/agent_protocol_server.pyindex 12e54582b1..131d2ad198 100644--- a/autogpts/autogpt/autogpt/app/agent_protocol_server.py+++ b/autogpts/autogpt/autogpt/app/agent_protocol_server.py@@ -25,6 +25,7 @@ from forge.sdk.model import (from forge.sdk.routes.agent_protocol import base_routerfrom hypercorn.asyncio import serve as hypercorn_servefrom hypercorn.config import Config as HypercornConfig+from sentry_sdk import set_userfrom autogpt.agent_factory.configurators import configure_agent_with_statefrom autogpt.agent_factory.generators import generate_agent_for_task@@ -121,6 +122,9 @@ class AgentProtocolServer:"""Create a task for the agent."""+ if user_id := (task_request.additional_input or {}).get("user_id"):+ set_user({"id": user_id})+task = await self.db.create_task(input=task_request.input,additional_input=task_request.additional_input,@@ -180,6 +184,9 @@ class AgentProtocolServer:llm_provider=self._get_task_llm_provider(task),)+ if user_id := (task.additional_input or {}).get("user_id"):+ set_user({"id": user_id})+# According to the Agent Protocol spec, the first execute_step request contains# the same task input as the parent create_task request.# To prevent this from interfering with the agent's process, we ignore the inputdiff --git a/autogpts/autogpt/autogpt/app/telemetry.py b/autogpts/autogpt/autogpt/app/telemetry.pyindex d64a74d5e0..ff865cc18c 100644--- a/autogpts/autogpt/autogpt/app/telemetry.py+++ b/autogpts/autogpt/autogpt/app/telemetry.py@@ -2,7 +2,7 @@ import osimport click-from .utils import env_file_exists, set_env_config_value+from .utils import env_file_exists, get_git_user_email, set_env_config_valuedef setup_telemetry() -> None:@@ -38,3 +38,6 @@ def _setup_sentry() -> None:dsn="https://dc266f2f7a2381194d1c0fa36dff67d8@o4505260022104064.ingest.sentry.io/4506739844710400", # noqaenvironment=os.getenv("TELEMETRY_ENVIRONMENT"),)++ # Allow Sentry to distinguish between users+ sentry_sdk.set_user({"email": get_git_user_email(), "ip_address": "{{auto}}"})diff --git a/autogpts/autogpt/autogpt/app/utils.py b/autogpts/autogpt/autogpt/app/utils.pyindex 99c72c84b2..5a2757161c 100644--- a/autogpts/autogpt/autogpt/app/utils.py+++ b/autogpts/autogpt/autogpt/app/utils.py@@ -84,6 +84,14 @@ def get_current_git_branch() -> str:return ""+def get_git_user_email() -> str:+ try:+ repo = Repo(search_parent_directories=True)+ return repo.config_reader().get_value("user", "email", default="")+ except InvalidGitRepositoryError:+ return ""++def get_latest_bulletin() -> tuple[str, bool]:exists = os.path.exists("data/CURRENT_BULLETIN.md")current_bulletin = ""