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

feat: implement the analytics SDK as a singleton #424

Conversation

1abhishekpandey
Copy link
Contributor

@1abhishekpandey 1abhishekpandey commented May 17, 2024

About the new feature

  • We have decided to implement the singleton pattern for the analytics SDK.
  • Multiple instance support is still present in the SDK in case we decide to support multiple instances in the future version of the SDK.
  • Now the user will always get an analytics instance when calling getInstance method. We have made sure that getInstance doesn't return null.

About the change

  • Changed createInstance API to getInstance and made it return a singleton instance. This logic has been moved into the new RudderAnalytics class.
  • Removed getInstance method which can return null.
  • Multiple instance support is still intact. We can use it in future when needed.
  • Removed the multiple instance-related code from the sample app.
  • Updated the test case to reflect the singleton pattern.
  • Moved AnalyticsUtil into the utilities package.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • Version upgraded (project, README, gradle, podspec etc)
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added unit tests for the code
  • I have made corresponding changes to the documentation

Copy link
Contributor

@ChryssaAliferi ChryssaAliferi left a comment

Choose a reason for hiding this comment

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

Nice effort, requesting some changes for alignment and for better kotlin implementation.

Copy link

sonarcloud bot commented May 20, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@ChryssaAliferi ChryssaAliferi left a comment

Choose a reason for hiding this comment

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

Simplified singleton instance and moving some ext functions to better suited place.
Great work!! Looks good to me!

@1abhishekpandey 1abhishekpandey merged commit 99bed42 into feat/android May 28, 2024
3 checks passed
@1abhishekpandey 1abhishekpandey deleted the feat/sdk-1801-change-multiple-instance-to-singleton-instance branch May 28, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants