diff --git a/aider/analytics.py b/aider/analytics.py index a1887e4a2..6295f9e3f 100644 --- a/aider/analytics.py +++ b/aider/analytics.py @@ -97,12 +97,12 @@ class Analytics: if not uuid_str: return False - # Convert percentage to hex threshold (1% = "04", 10% = "1a", etc) - # Using first 2 hex digits (0-ff) means each digit is 1/256 of the space + # Convert percentage to hex threshold (1% = "04...", 10% = "1a...", etc) + # Using first 6 hex digits if percent == 0: return False - threshold = format(int(255 * percent / 100), "02x") - return uuid_str[:2] <= threshold + threshold = format(int(0xFFFFFF * percent / 100), "06x") + return uuid_str[:6] <= threshold def get_data_file_path(self): data_file = Path.home() / ".aider" / "analytics.json" diff --git a/tests/basic/test_analytics.py b/tests/basic/test_analytics.py index 18194b1e8..dd25e12c8 100644 --- a/tests/basic/test_analytics.py +++ b/tests/basic/test_analytics.py @@ -113,6 +113,8 @@ def test_is_uuid_in_percentage(): # Test basic percentage thresholds assert analytics.is_uuid_in_percentage("00000000000000000000000000000000", 1) is True assert analytics.is_uuid_in_percentage("01999000000000000000000000000000", 1) is True + assert analytics.is_uuid_in_percentage("02000000000000000000000000000000", 1) is True + assert analytics.is_uuid_in_percentage("02910000000000000000000000000001", 1) is False assert analytics.is_uuid_in_percentage("03000000000000000000000000000000", 1) is False assert analytics.is_uuid_in_percentage("ff000000000000000000000000000000", 1) is False