Skip to content

Commit b3f6517

Browse files
authored
Merge pull request #168 from AgentOps-AI/auth-telemetry
telem with user token
2 parents 1f12f53 + 40578bb commit b3f6517

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

agentstack/telemetry.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import psutil
2929
import requests
3030
from agentstack import conf
31+
from agentstack.auth import get_stored_token
3132
from agentstack.utils import get_telemetry_opt_out, get_framework, get_version
3233

3334
TELEMETRY_URL = 'https://api.agentstack.sh/telemetry'
@@ -77,7 +78,12 @@ def collect_machine_telemetry(command: str):
7778
def track_cli_command(command: str, args: Optional[str] = None):
7879
try:
7980
data = collect_machine_telemetry(command)
80-
return requests.post(TELEMETRY_URL, json={"command": command, "args":args, **data}).json().get('id')
81+
headers = {}
82+
token = get_stored_token()
83+
if token:
84+
headers['Authorization'] = f'Bearer {token}'
85+
86+
return requests.post(TELEMETRY_URL, json={"command": command, "args":args, **data}, headers=headers).json().get('id')
8187
except Exception:
8288
pass
8389

0 commit comments

Comments
 (0)