mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
fix: Disable analytics by default and provide option to enable
This commit is contained in:
parent
4ebbfa01b7
commit
aeadf2f139
3 changed files with 20 additions and 6 deletions
|
@ -10,10 +10,15 @@ from mixpanel import Mixpanel
|
||||||
from aider import __version__
|
from aider import __version__
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
|
|
||||||
DATA_FILE_NAME = "mixpanel.json"
|
project_token = "6da9a43058a5d1b9f3353153921fb04d"
|
||||||
|
|
||||||
|
|
||||||
class Analytics:
|
class Analytics:
|
||||||
|
mp = None
|
||||||
|
user_id = None
|
||||||
|
disable = None
|
||||||
|
logfile = None
|
||||||
|
|
||||||
def __init__(self, track, logfile=None, disable=False):
|
def __init__(self, track, logfile=None, disable=False):
|
||||||
self.logfile = logfile
|
self.logfile = logfile
|
||||||
self.disable = disable
|
self.disable = disable
|
||||||
|
@ -23,12 +28,13 @@ class Analytics:
|
||||||
self.mark_as_disabled()
|
self.mark_as_disabled()
|
||||||
return
|
return
|
||||||
|
|
||||||
project_token = "6da9a43058a5d1b9f3353153921fb04d"
|
|
||||||
self.mp = Mixpanel(project_token) if project_token else None
|
|
||||||
self.user_id = self.get_or_create_uuid()
|
self.user_id = self.get_or_create_uuid()
|
||||||
|
|
||||||
|
if self.user_id and not self.disable:
|
||||||
|
self.mp = Mixpanel(project_token)
|
||||||
|
|
||||||
def get_data_file_path(self):
|
def get_data_file_path(self):
|
||||||
data_file = Path.home() / ".aider" / "caches" / DATA_FILE_NAME
|
data_file = Path.home() / ".aider" / "analytics.json"
|
||||||
data_file.parent.mkdir(parents=True, exist_ok=True)
|
data_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
return data_file
|
return data_file
|
||||||
|
|
||||||
|
@ -44,9 +50,11 @@ class Analytics:
|
||||||
if data_file.exists():
|
if data_file.exists():
|
||||||
with open(data_file, "r") as f:
|
with open(data_file, "r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
dump(data)
|
||||||
if "disabled" in data and data["disabled"]:
|
if "disabled" in data and data["disabled"]:
|
||||||
self.disable = True
|
self.disable = True
|
||||||
self.mp = None
|
self.mp = None
|
||||||
|
return
|
||||||
return data["uuid"]
|
return data["uuid"]
|
||||||
|
|
||||||
new_uuid = str(uuid.uuid4())
|
new_uuid = str(uuid.uuid4())
|
||||||
|
|
|
@ -334,6 +334,11 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
# Parse again to include any arguments that might have been defined in .env
|
# Parse again to include any arguments that might have been defined in .env
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
|
if args.analytics_disable:
|
||||||
|
analytics = Analytics(track=False, disable=True)
|
||||||
|
print("Analytics have been permanently disabled.")
|
||||||
|
return
|
||||||
|
|
||||||
if not args.verify_ssl:
|
if not args.verify_ssl:
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ nav_order: 500
|
||||||
|
|
||||||
Aider uses MixPanel to collect anonymous analytics that are used to help
|
Aider uses MixPanel to collect anonymous analytics that are used to help
|
||||||
improve aider.
|
improve aider.
|
||||||
**Analytics is currently turned off by default**, but expected to be turned on by default in
|
**Analytics are currently turned off by default**, but are
|
||||||
|
expected to be turned on by default in
|
||||||
a future release.
|
a future release.
|
||||||
|
|
||||||
## Anonymous, no personal info
|
## Anonymous, no personal info
|
||||||
|
@ -35,7 +36,7 @@ personal use of aider.
|
||||||
|
|
||||||
## Enabling & disabling analytics
|
## Enabling & disabling analytics
|
||||||
|
|
||||||
You can easily opt out of analytics forever by running this command one time:
|
You can opt out of analytics forever by running this command one time:
|
||||||
|
|
||||||
```
|
```
|
||||||
aider --analytics-disable
|
aider --analytics-disable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue