The telemetry system is implemented but not actively integrated into the PraisonAI Agents codebase. While PostHog is properly configured and functional, telemetry data is never sent because:
- No automatic integration: Agent and PraisonAIAgents classes don't use telemetry
- No automatic flush: Events are collected but never sent to PostHog
- No lifecycle hooks: No atexit handler or periodic flush mechanism
- PostHog client is properly initialized with API key and host
- Telemetry can be enabled/disabled via environment variables
- Privacy-first design with anonymous tracking
- Manual telemetry tracking and flushing works correctly
- Agent class doesn't integrate telemetry
- PraisonAIAgents class doesn't integrate telemetry
- No automatic flush() calls anywhere in the codebase
- Integration module (integration.py) is not used
# Lines 84-93: PostHog is initialized correctly
if POSTHOG_AVAILABLE:
try:
self._posthog = Posthog(
project_api_key='phc_skZpl3eFLQJ4iYjsERNMbCO6jfeSJi2vyZlPahKgxZ7',
host='https://eu.i.posthog.com'
)
except:
self._posthog = None# Lines 208-224: flush() sends events but is never called automatically
def flush(self):
if hasattr(self, '_posthog') and self._posthog:
try:
self._posthog.capture(
distinct_id='anonymous',
event='sdk_used',
properties={...}
)
self._posthog.capture('test-id', 'test-event')
except:
pass- No telemetry imports
- No telemetry initialization in init
- No telemetry tracking in start(), run(), or execute_tool()
- No telemetry imports
- No telemetry initialization
- No telemetry tracking in start() or workflow execution
- Incomplete Implementation: The telemetry system was built but never integrated into the main classes
- No Automatic Lifecycle Management: No atexit handler or periodic flush
- Integration Module Not Used:
integration.pyhas the code but it's never imported/called
- Add automatic integration to Agent class:
# In agent/agent.py __init__
from ..telemetry import get_telemetry
self._telemetry = get_telemetry()
# In start() method
if self._telemetry and self._telemetry.enabled:
self._telemetry.track_agent_execution(self.name, success=True)- Add atexit handler in telemetry.py:
import atexit
def _flush_on_exit():
if _telemetry_instance:
_telemetry_instance.flush()
atexit.register(_flush_on_exit)- Add periodic flush:
# Flush after N events or T seconds
if self._metrics["total_events"] >= 100:
self.flush()- Make telemetry opt-in by default with clear documentation
- Add telemetry configuration options (flush interval, batch size)
- Implement proper error handling for network failures
- Add telemetry dashboard for users to see their usage
Created test files demonstrate:
test_posthog.py: PostHog is working correctlytest_posthog_detailed.py: Events are sent when flush() is calledtest_telemetry_integration.py: Integration is missing
The telemetry infrastructure is well-designed but incomplete. The main issue is that telemetry code exists in isolation and is never called by the core Agent/PraisonAIAgents classes. Additionally, even if it were integrated, the lack of automatic flush mechanisms means data would never reach PostHog.