mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 04:35:00 +00:00
disabled -> permanently_disabled
This commit is contained in:
parent
607a9a8c86
commit
4759297b67
3 changed files with 15 additions and 14 deletions
|
@ -20,22 +20,22 @@ class Analytics:
|
||||||
mp = None
|
mp = None
|
||||||
ph = None
|
ph = None
|
||||||
user_id = None
|
user_id = None
|
||||||
disable = None
|
permanently_disable = None
|
||||||
logfile = None
|
logfile = None
|
||||||
|
|
||||||
def __init__(self, enable=False, logfile=None, disable=False):
|
def __init__(self, enable=False, logfile=None, permanently_disable=False):
|
||||||
self.logfile = logfile
|
self.logfile = logfile
|
||||||
self.disable = disable
|
self.permanently_disable = permanently_disable
|
||||||
if not enable or disable:
|
if not enable or permanently_disable:
|
||||||
self.mp = None
|
self.mp = None
|
||||||
self.ph = None
|
self.ph = None
|
||||||
if disable:
|
if permanently_disable:
|
||||||
self.mark_as_disabled()
|
self.mark_as_permanently_disabled()
|
||||||
return
|
return
|
||||||
|
|
||||||
self.user_id = self.get_or_create_uuid()
|
self.user_id = self.get_or_create_uuid()
|
||||||
|
|
||||||
if self.user_id and not self.disable:
|
if self.user_id and not self.permanently_disable:
|
||||||
self.mp = Mixpanel(mixpanel_project_token)
|
self.mp = Mixpanel(mixpanel_project_token)
|
||||||
self.ph = Posthog(project_api_key=posthog_project_api_key, host=posthog_host)
|
self.ph = Posthog(project_api_key=posthog_project_api_key, host=posthog_host)
|
||||||
|
|
||||||
|
@ -44,14 +44,14 @@ class Analytics:
|
||||||
data_file.parent.mkdir(parents=True, exist_ok=True)
|
data_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
return data_file
|
return data_file
|
||||||
|
|
||||||
def mark_as_disabled(self):
|
def mark_as_permanently_disabled(self):
|
||||||
data_file = self.get_data_file_path()
|
data_file = self.get_data_file_path()
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
data = {"uuid": str(uuid.uuid4())}
|
data = {"uuid": str(uuid.uuid4())}
|
||||||
data["disabled"] = True
|
data["permanently_disabled"] = True
|
||||||
with open(data_file, "w") as f:
|
with open(data_file, "w") as f:
|
||||||
json.dump(data, f)
|
json.dump(data, f)
|
||||||
|
|
||||||
|
@ -61,9 +61,10 @@ 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)
|
||||||
if "disabled" in data and data["disabled"]:
|
if "permanently_disabled" in data and data["permanently_disabled"]:
|
||||||
self.disable = True
|
self.permanently_disable = True
|
||||||
self.mp = None
|
self.mp = None
|
||||||
|
self.ph = None
|
||||||
return
|
return
|
||||||
return data["uuid"]
|
return data["uuid"]
|
||||||
|
|
||||||
|
|
|
@ -451,7 +451,7 @@ def get_parser(default_config_files, git_root):
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--analytics-disable",
|
"--analytics-disable",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Disable analytics forever",
|
help="Permanently disable analytics",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -346,7 +346,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
if args.analytics_disable:
|
if args.analytics_disable:
|
||||||
analytics = Analytics(enable=False, disable=True)
|
analytics = Analytics(enable=False, permanently_disable=True)
|
||||||
print("Analytics have been permanently disabled.")
|
print("Analytics have been permanently disabled.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
)
|
)
|
||||||
|
|
||||||
analytics = Analytics(
|
analytics = Analytics(
|
||||||
args.analytics, logfile=args.analytics_log, disable=args.analytics_disable
|
args.analytics, logfile=args.analytics_log, permanently_disable=args.analytics_disable
|
||||||
)
|
)
|
||||||
analytics.event("launched")
|
analytics.event("launched")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue