Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

telem with user token #168

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion agentstack/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import psutil
import requests
from agentstack import conf
from agentstack.auth import get_stored_token
from agentstack.utils import get_telemetry_opt_out, get_framework, get_version

TELEMETRY_URL = 'https://api.agentstack.sh/telemetry'
Expand Down Expand Up @@ -77,7 +78,12 @@ def collect_machine_telemetry(command: str):
def track_cli_command(command: str, args: Optional[str] = None):
try:
data = collect_machine_telemetry(command)
return requests.post(TELEMETRY_URL, json={"command": command, "args":args, **data}).json().get('id')
headers = {}
token = get_stored_token()
if token:
headers['Authorization'] = f'Bearer {token}'

return requests.post(TELEMETRY_URL, json={"command": command, "args":args, **data}, headers=headers).json().get('id')
except Exception:
pass

Expand Down
Loading