diff --git a/aider/analytics.py b/aider/analytics.py index f994a804f..6a889a876 100644 --- a/aider/analytics.py +++ b/aider/analytics.py @@ -50,8 +50,10 @@ class Analytics: self.disable(False) return - self.mp = Mixpanel(mixpanel_project_token) - self.ph = Posthog(project_api_key=posthog_project_api_key, host=posthog_host) + # self.mp = Mixpanel(mixpanel_project_token) + self.ph = Posthog( + project_api_key=posthog_project_api_key, host=posthog_host, on_error=self.posthog_error + ) def disable(self, permanently): self.mp = None @@ -172,6 +174,12 @@ class Analytics: return model.name.split("/")[0] + "/REDACTED" return None + def posthog_error(self): + """disable posthog if we get an error""" + # https://github.com/PostHog/posthog-python/blob/9e1bb8c58afaa229da24c4fb576c08bb88a75752/posthog/consumer.py#L86 + # https://github.com/Aider-AI/aider/issues/2532 + self.ph = None + def event(self, event_name, main_model=None, **kwargs): if not self.mp and not self.ph and not self.logfile: return