Skip to content
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

Use of plugin as a singleton #11

Closed
debkanchan opened this issue Jul 7, 2023 · 2 comments
Closed

Use of plugin as a singleton #11

debkanchan opened this issue Jul 7, 2023 · 2 comments

Comments

@debkanchan
Copy link
Contributor

In this current form, this plugin requires that the user create an analytics instance and use it throughout the app, which requires either

  • using a global analytics variable (which is not recommended and is an antipattern)
  • wrapping it with a singleton class(inconvenient)
  • dependency injecting it (using prop drilling or state management solutions).

Rather than this, it would be beneficial if it was a singleton instance like Segment.Instance just like how Firebase analytics does it with FirebaseAnalytics.Instance

@edsonjab
Copy link
Contributor

Hi @DebkanchanSamadder thank you for your report, we start looking into this and we will check your PR.

@oscb
Copy link
Contributor

oscb commented Feb 8, 2024

Not doing singletons is part of the design of the library to enable support for multiple clients by default. This is better to handle per app at the moment.

@oscb oscb closed this as completed Feb 8, 2024
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 a pull request may close this issue.

3 participants