From 75f52a132406ac877401695da30f27344926b708 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Wed, 20 Nov 2024 17:52:52 -0800 Subject: [PATCH] refactor: Improve user sampling logic with configurable percentage --- aider/analytics.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aider/analytics.py b/aider/analytics.py index e702b8f41..537da259e 100644 --- a/aider/analytics.py +++ b/aider/analytics.py @@ -78,8 +78,11 @@ class Analytics: if not self.user_id: return False - # ask 1% of users - return self.user_id < "03" + # Define percentage of users to ask + PERCENT = 1 + # Convert percentage to hex threshold (1% = "03", 10% = "1a", etc) + threshold = format(int(256 * PERCENT / 100), "02x") + return self.user_id < threshold def get_data_file_path(self): data_file = Path.home() / ".aider" / "analytics.json"