feat(agent/telemetry): Enable performance tracing & update opt-in prompt accordingly

This commit is contained in:
Reinier van der Leer
2024-02-15 14:46:36 +01:00
parent 8762f7ab3d
commit b7f08cd0f7

View File

@@ -1,6 +1,7 @@
import os
import click
from colorama import Fore, Style
from .utils import env_file_exists, get_git_user_email, set_env_config_value
@@ -12,25 +13,31 @@ def setup_telemetry() -> None:
if not env_file_exists():
return
print()
allow_telemetry = click.prompt(
"❓ Do you want to enable telemetry? ❓\n"
"This means AutoGPT will send diagnostic data to the core development team "
"when something goes wrong,\n"
"and will help us to diagnose and fix problems earlier and faster.\n"
"\n"
"By entering 'yes', you confirm that you have read and agree to our "
"Privacy Policy, which is available here:\n"
"https://www.notion.so/auto-gpt/Privacy-Policy-ab11c9c20dbd4de1a15dcffe84d77984\n" # noqa
"\n"
"Please enter 'yes' or 'no'",
f"""
{Style.BRIGHT}❓ Do you want to enable telemetry? ❓{Style.NORMAL}
This means AutoGPT will send diagnostic data to the core development team when something
goes wrong, and will help us to diagnose and fix problems earlier and faster. It also
allows us to collect basic performance data, which helps us find bottlenecks and other
things that slow down the application.
By entering 'yes', you confirm that you have read and agree to our Privacy Policy,
which is available here:
https://www.notion.so/auto-gpt/Privacy-Policy-ab11c9c20dbd4de1a15dcffe84d77984
Please enter 'yes' or 'no'""",
type=bool,
)
set_env_config_value("TELEMETRY_OPT_IN", "true" if allow_telemetry else "false")
print(
"💡 If you ever change your mind, you can adjust 'TELEMETRY_OPT_IN' in .env"
click.echo(
f"❤️ Thank you! Telemetry is {Fore.GREEN}enabled{Fore.RESET}."
if allow_telemetry
else f"👍 Telemetry is {Fore.RED}disabled{Fore.RESET}."
)
print()
click.echo(
"💡 If you ever change your mind, you can change 'TELEMETRY_OPT_IN' in .env"
)
click.echo()
if os.getenv("TELEMETRY_OPT_IN", "").lower() == "true":
_setup_sentry()
@@ -41,6 +48,7 @@ def _setup_sentry() -> None:
sentry_sdk.init(
dsn="https://dc266f2f7a2381194d1c0fa36dff67d8@o4505260022104064.ingest.sentry.io/4506739844710400", # noqa
enable_tracing=True,
environment=os.getenv("TELEMETRY_ENVIRONMENT"),
)