-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not allow default integrations multiple times #219
Conversation
## 3.11.0 - 2025-01-27 | ||
|
||
- chore: Session Replay - GA | ||
- fix: session replay and auto capture works with 'with' method ([#217](https://github.com/PostHog/posthog-flutter/pull/217)) | ||
- fix: sending cached events null check ([#218](https://github.com/PostHog/posthog-flutter/pull/218)) | ||
- fix: session replay and auto capture works with 'with' method ([#217](https://github.com/PostHog/posthog-android/pull/217)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ups, copy-pasta error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not convinced if this is the right approach tbh.
Integrations are effectively handled in a first-come first-served basis, so instance creation order matters here, which could be problematic. If instance creation happens in a non-deterministic order as well, then this will lead to unpredictable results down the line.
Consider this scenario:
- HostApp integrates with PostHogSDK.
- HostApp also integrates with SomeOtherSDK.
- SomeOtherSDK, in turn, integrates with PostHogSDK.
- Both HostApp and SomeOtherSDK enable all integrations in config (session replay, autocapture, etc.).
In this setup, whichever SDK calls .setup() or .with() first takes precedence. This could introduce inconsistent behavior if the call order is not guaranteed—sometimes the HostApp gets all the active integrations, while other times SomeOtherSDK does.
Broadly speaking, I feel this ties back to how we handle multiple PostHog SDK instances.
Maybe a more robust solution would be to introduce a mechanism in the instance creation process that will ensure a single PostHogSDK instance per API key, each with its own configuration and set of active integrations:
- Calling .with(apiKey: "project_one_api_key") multiple times should always return the same PostHogSDK instance, ensuring that integrations are installed only once and that events, session replays, and autocapture are delivered to the "project_one_api_key" project.
- Similarly, calling .with(apiKey: "project_two_api_key") should create a separate instance for that project with its own set of integrations, sending data specifically to the "project_two_api_key" project.
In the scenario above, HostAp and SomeOtherSDK will get a seprate PostHogSDK instance, with all integrations active for each.
wdyt?
discussed this offline. |
@ioannisj @PostHog/team-replay can I has a review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
low context 👍
💡 Motivation and Context
follow up #217 and #216 (comment)
if multiple instances are created using the
with
method, we might send data wrongly or too much.💚 How did you test it?
📝 Checklist