Skip to content

Show warning when instantiating multiple ruby clients#109

Merged
dustinbyrne merged 2 commits intoPostHog:mainfrom
Hanaffi:use-singleton
Mar 12, 2026
Merged

Show warning when instantiating multiple ruby clients#109
dustinbyrne merged 2 commits intoPostHog:mainfrom
Hanaffi:use-singleton

Conversation

@Hanaffi
Copy link
Contributor

@Hanaffi Hanaffi commented Mar 9, 2026

Closes: #57
AI Disclosure: I used Cursor for this PR.


  • Added a warning mechanism for multiple PostHog client instances created with the same API key to prevent dropped events and inconsistent behavior.
  • Updated documentation to emphasize the importance of using a single client instance and provided guidance on suppressing the warning if multiple instances are necessary.
  • Enhanced tests to verify the warning functionality and ensure correct behavior under various conditions.

This change improves the reliability of the PostHog integration by promoting best practices for client usage.

- Added a warning mechanism for multiple PostHog client instances created with the same API key to prevent dropped events and inconsistent behavior.
- Updated documentation to emphasize the importance of using a single client instance and provided guidance on suppressing the warning if multiple instances are necessary.
- Enhanced tests to verify the warning functionality and ensure correct behavior under various conditions.

This change improves the reliability of the PostHog integration by promoting best practices for client usage.
@dustinbyrne dustinbyrne requested a review from a team March 9, 2026 17:42
@dustinbyrne
Copy link
Contributor

This looks good to me, thanks for submitting!

I'll have to circle back to check out the issue with Semgrep failing to run before approving.

Copy link
Contributor

@dustinbyrne dustinbyrne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Hanaffi!

@dustinbyrne dustinbyrne merged commit 3a3bbea into PostHog:main Mar 12, 2026
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: Enforce instantiating the Ruby client as a singleton (or provide warnings)

2 participants