diff --git a/aider/analytics.py b/aider/analytics.py index b9cf7b65e..1364bc982 100644 --- a/aider/analytics.py +++ b/aider/analytics.py @@ -10,10 +10,15 @@ from mixpanel import Mixpanel from aider import __version__ from aider.dump import dump # noqa: F401 -DATA_FILE_NAME = "mixpanel.json" +project_token = "6da9a43058a5d1b9f3353153921fb04d" class Analytics: + mp = None + user_id = None + disable = None + logfile = None + def __init__(self, track, logfile=None, disable=False): self.logfile = logfile self.disable = disable @@ -23,12 +28,13 @@ class Analytics: self.mark_as_disabled() return - project_token = "6da9a43058a5d1b9f3353153921fb04d" - self.mp = Mixpanel(project_token) if project_token else None 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): - 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) return data_file @@ -44,9 +50,11 @@ class Analytics: if data_file.exists(): with open(data_file, "r") as f: data = json.load(f) + dump(data) if "disabled" in data and data["disabled"]: self.disable = True self.mp = None + return return data["uuid"] new_uuid = str(uuid.uuid4()) diff --git a/aider/main.py b/aider/main.py index bc553db2c..682b143c1 100644 --- a/aider/main.py +++ b/aider/main.py @@ -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 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: import httpx diff --git a/aider/website/docs/more/analytics.md b/aider/website/docs/more/analytics.md index 12460013f..5eedc4226 100644 --- a/aider/website/docs/more/analytics.md +++ b/aider/website/docs/more/analytics.md @@ -7,7 +7,8 @@ nav_order: 500 Aider uses MixPanel to collect anonymous analytics that are used to help 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. ## Anonymous, no personal info @@ -35,7 +36,7 @@ personal use of aider. ## 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