Skip to content

Commit

Permalink
dont error from telemetry on init
Browse files Browse the repository at this point in the history
  • Loading branch information
bboynton97 committed Nov 26, 2024
1 parent 281fc3a commit 2148671
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions agentstack/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

TELEMETRY_URL = 'https://api.agentstack.sh/telemetry'

def collect_machine_telemetry():
def collect_machine_telemetry(command: str):
if get_telemetry_opt_out():
return

Expand All @@ -43,10 +43,14 @@ def collect_machine_telemetry():
'os_version': platform.version(),
'cpu_count': psutil.cpu_count(logical=True),
'memory': psutil.virtual_memory().total,
'framework': get_framework(),
'agentstack_version': get_version()
}

if command is not "init":
telemetry_data['framework'] = get_framework()
else:
telemetry_data['framework'] = "n/a"

# Attempt to get general location based on public IP
try:
response = requests.get('https://ipinfo.io/json')
Expand All @@ -64,9 +68,9 @@ def collect_machine_telemetry():
return telemetry_data


def track_cli_command(command):
def track_cli_command(command: str):
try:
data = collect_machine_telemetry()
data = collect_machine_telemetry(command)
requests.post(TELEMETRY_URL, json={"command": command, **data})
except:
pass

0 comments on commit 2148671

Please sign in to comment.