Remove unused functions

This commit is contained in:
James Murdza
2025-08-11 08:50:57 -04:00
parent a1020161bd
commit 1dc2d69f16
2 changed files with 2 additions and 96 deletions

View File

@@ -213,41 +213,6 @@ class PostHogTelemetryClient:
logger.warning("Using random installation ID (will not persist across runs)")
return str(uuid.uuid4())
def increment(self, counter_name: str, value: int = 1) -> None:
"""Increment a named counter.
Args:
counter_name: Name of the counter
value: Amount to increment by (default: 1)
"""
if not self.config.enabled:
return
# Apply sampling to reduce number of events
if random.random() * 100 > self.config.sample_rate:
return
properties = {
"value": value,
"counter_name": counter_name,
"version": __version__,
}
if self.initialized:
try:
posthog.capture(
distinct_id=self.installation_id,
event="counter_increment",
properties=properties,
)
except Exception as e:
logger.debug(f"Failed to send counter event to PostHog: {e}")
else:
# Queue the event for later
self.queued_events.append({"event": "counter_increment", "properties": properties})
# Try to initialize now if not already
self._initialize_posthog()
def record_event(self, event_name: str, properties: Optional[Dict[str, Any]] = None) -> None:
"""Record an event with optional properties.
@@ -307,21 +272,6 @@ class PostHogTelemetryClient:
logger.debug(f"Failed to flush PostHog events: {e}")
return False
def enable(self) -> None:
"""Enable telemetry collection."""
self.config.enabled = True
if posthog:
posthog.disabled = False
logger.info("Telemetry enabled")
self._initialize_posthog()
def disable(self) -> None:
"""Disable telemetry collection."""
self.config.enabled = False
if posthog:
posthog.disabled = True
logger.info("Telemetry disabled")
# Global telemetry client instance
_client: Optional[PostHogTelemetryClient] = None
@@ -338,10 +288,4 @@ def get_posthog_telemetry_client() -> PostHogTelemetryClient:
if _client is None:
_client = PostHogTelemetryClient()
return _client
def disable_telemetry() -> None:
"""Disable telemetry collection globally."""
if _client is not None:
_client.disable()
return _client

View File

@@ -5,7 +5,6 @@ Usage:
from core.telemetry import record_event, increment
record_event("my_event", {"foo": "bar"})
increment("my_counter")
Configuration:
• Disable telemetry globally by setting the environment variable
@@ -90,45 +89,8 @@ def is_telemetry_enabled() -> bool:
_ensure_client()
return _ENABLED and not _telemetry_disabled()
def enable() -> None:
"""Enable telemetry collection for this process (unless globally disabled)."""
global _ENABLED
if _telemetry_disabled():
_LOGGER.info("Telemetry has been disabled via environment variable.")
return
_ensure_client()
if _CLIENT:
_CLIENT.enable()
_ENABLED = True
def disable() -> None:
"""Disable telemetry for this process."""
global _ENABLED
if _CLIENT:
_CLIENT.disable()
_ENABLED = False
def record_event(event_name: str, properties: Optional[Dict[str, Any]] | None = None) -> None:
"""Send an arbitrary PostHog event."""
_ensure_client()
if _CLIENT and _ENABLED:
_CLIENT.record_event(event_name, properties or {})
def increment(counter_name: str, value: int = 1) -> None:
"""Increment a named counter."""
_ensure_client()
if _CLIENT and _ENABLED:
_CLIENT.increment(counter_name, value)
def flush() -> bool:
"""Flush any queued analytics events to PostHog."""
_ensure_client()
return bool(_CLIENT and _ENABLED and _CLIENT.flush())
_CLIENT.record_event(event_name, properties or {})