|
| 1 | +# hi :) |
| 2 | +# |
| 3 | +# if you're reading this, you probably saw "telemetry.py" and |
| 4 | +# got mad and went to go see how we're spying on you |
| 5 | +# |
| 6 | +# i really hate to put this functionality in and was very |
| 7 | +# resistant to it. as a human, i value privacy as a fundamental |
| 8 | +# human right. but i also value my time. |
| 9 | +# |
| 10 | +# i have been putting a lot of my time into building out |
| 11 | +# agentstack. i have strong conviction for what this project |
| 12 | +# can be. it's showing some great progress, but for me to justify |
| 13 | +# spending days and nights building this, i need to know that |
| 14 | +# people are actually using it and not just starring the repo |
| 15 | +# |
| 16 | +# if you want to opt-out of telemetry, you can add the following |
| 17 | +# configuration to your agentstack.json file: |
| 18 | +# |
| 19 | +# telemetry_opt_out: false |
| 20 | +# |
| 21 | +# i'm a single developer with a passion, working to lower the barrier |
| 22 | +# of entry to building and deploying agents. it would be really |
| 23 | +# cool of you to allow telemetry <3 |
| 24 | +# |
| 25 | +# - braelyn |
| 26 | + |
| 27 | +import platform |
| 28 | +import socket |
| 29 | +import psutil |
| 30 | +import requests |
| 31 | +from agentstack.utils import get_telemetry_opt_out, get_framework, get_version |
| 32 | + |
| 33 | +# TELEMETRY_URL = 'https://api.agentstack.sh/telemetry' |
| 34 | +TELEMETRY_URL = 'http://localhost:3000/telemetry' |
| 35 | + |
| 36 | +def collect_machine_telemetry(): |
| 37 | + if get_telemetry_opt_out(): |
| 38 | + return |
| 39 | + |
| 40 | + telemetry_data = { |
| 41 | + 'os': platform.system(), |
| 42 | + 'hostname': socket.gethostname(), |
| 43 | + 'platform': platform.platform(), |
| 44 | + 'os_version': platform.version(), |
| 45 | + 'cpu_count': psutil.cpu_count(logical=True), |
| 46 | + 'memory': psutil.virtual_memory().total, |
| 47 | + 'framework': get_framework(), |
| 48 | + 'agentstack_version': get_version() |
| 49 | + } |
| 50 | + |
| 51 | + # Attempt to get general location based on public IP |
| 52 | + try: |
| 53 | + response = requests.get('https://ipinfo.io/json') |
| 54 | + if response.status_code == 200: |
| 55 | + location_data = response.json() |
| 56 | + telemetry_data.update({ |
| 57 | + 'ip': location_data.get('ip'), |
| 58 | + 'city': location_data.get('city'), |
| 59 | + 'region': location_data.get('region'), |
| 60 | + 'country': location_data.get('country') |
| 61 | + }) |
| 62 | + except requests.RequestException as e: |
| 63 | + telemetry_data['location_error'] = str(e) |
| 64 | + |
| 65 | + return telemetry_data |
| 66 | + |
| 67 | + |
| 68 | +def track_cli_command(command): |
| 69 | + try: |
| 70 | + data = collect_machine_telemetry() |
| 71 | + requests.post(TELEMETRY_URL, json={"command": command, **data}) |
| 72 | + except: |
| 73 | + pass |
0 commit comments