refactor: Improve user sampling logic with configurable percentage

This commit is contained in:
Paul Gauthier (aider) 2024-11-20 17:52:52 -08:00
parent 6e076a40a9
commit 75f52a1324

View file

@ -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"