Full context can be found here: https://posthog.slack.com/archives/C03P7NL6RMW/p1733514026622539, but here's the summary for external stakeholders:
Issue:
- Users were experiencing dropped events when using the Python SDK
- Feature flag events were being captured but other events weren't
- Investigation revealed multiple SDK client instances were being instantiated
- No warnings/exceptions were thrown on multiple client instantiations
Root Cause:
- The SDK doesn't enforce a singleton pattern for client instances
- Multiple client instances in the same application can cause event capture issues
- This becomes particularly problematic in containerized environments like Kubernetes
Solution:
- Implement a singleton factory pattern to prevent multiple client instantiations
- Add explicit warnings/exceptions when users try to create multiple clients
- Update documentation to:
- Clearly explain the singleton requirement
- Provide best practices for client instantiation
- Include guidance for complex infrastructure setups