PostHog / posthog-flutter

PostHog Flutter SDK
https://posthog.com/docs/libraries/flutter
MIT License
55 stars 37 forks source link

Duplicate posthog client created with tag #61

Closed mattbajorek closed 11 months ago

mattbajorek commented 1 year ago

Version

Flutter version: >=3.0.6 <4.0.0 Posthog version: 3.3.0

Expected Result

No duplicate client should be called.

Actual Result

Duplicate posthog client created with tag: {secret posthog tag}. If you want to use multiple PostHog clients, use a different apiKey or set a tag via the builder during construction.

Steps to Reproduce

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final postHog = Posthog(); // this will give the error
}
marandaneto commented 1 year ago

@mattbajorek thanks for the report. Is this happening on Android or iOS? is it happening after hot-reload or just after opening the app? Did you configure the other things such as com.posthog.posthog.API_KEY? See the docs

mattbajorek commented 1 year ago

@marandaneto I haven't tested on iOS, I was encountering this issue on Android. I have the AndroidManifest.xml as show in the docs. I didn't want to post my API_KEY, but I verified the API key was set properly.

marandaneto commented 1 year ago

@mattbajorek I've tried it out and can't reproduce this, I only see the Created posthog client for project with tag {tag}, even after hot reloading.

Posthog() is just a singleton factory, so it's not even creating an instance every time, the plugin is only installed once during app start.

Can you provide a minimum reproducible example?

marandaneto commented 11 months ago

Closing the issue as a part of large repository cleanup, due to it being inactive and/or outdated. Please do not hesitate to ping me if it is still relevant, and I will happily reopen and work on it. Cheers!