update to only use CUA_TELEMETRY_ENABLED

This commit is contained in:
Sarina Li
2025-11-29 22:41:27 -05:00
parent f38283c8f4
commit 26caedf492
7 changed files with 40 additions and 34 deletions

View File

@@ -44,13 +44,12 @@ class PostHogTelemetryClient:
@classmethod
def is_telemetry_enabled(cls) -> bool:
"""True if telemetry is currently active for this process."""
return (
# Legacy opt-out flag
os.environ.get("CUA_TELEMETRY", "").lower() != "off"
# Opt-in flag (defaults to enabled)
and os.environ.get("CUA_TELEMETRY_ENABLED", "true").lower()
in {"1", "true", "yes", "on"}
)
return os.environ.get("CUA_TELEMETRY_ENABLED", "true").lower() in {
"1",
"true",
"yes",
"on",
}
def _get_or_create_installation_id(self) -> str:
"""Get or create a unique installation ID that persists across runs.

View File

@@ -24,15 +24,7 @@ class TestTelemetryEnabled:
assert is_telemetry_enabled() is True
def test_telemetry_disabled_with_legacy_flag(self, monkeypatch):
"""Test that telemetry can be disabled with legacy CUA_TELEMETRY=off."""
monkeypatch.setenv("CUA_TELEMETRY", "off")
from core.telemetry import is_telemetry_enabled
assert is_telemetry_enabled() is False
def test_telemetry_disabled_with_new_flag(self, monkeypatch):
def test_telemetry_disabled_with_flag(self, monkeypatch):
"""Test that telemetry can be disabled with CUA_TELEMETRY_ENABLED=false."""
monkeypatch.setenv("CUA_TELEMETRY_ENABLED", "false")