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: check connection availability before fetching sourceConfig #103

Open
wants to merge 9 commits into
base: feat/sdk-2850-implementation-network-observer-using-plugin
Choose a base branch
from

Conversation

1abhishekpandey
Copy link
Contributor

@1abhishekpandey 1abhishekpandey commented Jan 14, 2025

Description

  • In this PR, we’ve added logic to check and wait for the connection to be available before attempting to fetch the sourceConfig. This ensures that the sourceConfig is not fetched until the network is available.

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)
  • Documentation update
  • Code refactor/optimization

Implementation Details

SourceConfigManager

  • First, we will fetch the cached sourceConfig from storage, if available, and immediately notify the observers with the cached sourceConfig.
  • Then, we will refresh the sourceConfig by downloading the latest version, store it, and notify all observers.
  • Added test cases: Rewrote them from scratch.

Core Analytics

  • Refactored the setup portion of the core Analytics

LoggerAnalytics

  • Improved LoggerAnalytics by handling edge cases. I noticed that if it’s not initialized early in the lifecycle and a message is logged, it throws a fatal exception. Now, in such cases, we simply ignore any logging requests.

Checklist

  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation (if appropriate).
  • I have ensured that my code follows the project's code style.
  • I have checked for potential performance impacts and optimized if necessary.
  • I have checked the code for security issues.
  • I have updated the changelog (if required).

How to test?

  • Run the Android app and toggle on the connection. The SC will be immediately fetched, as soon as the connection becomes available.
  • Run the Android app on different SDK API versions i.e., compatible SDK version - API 24 and above and legacy once API 21 - 23.
  • Run the core module, and an attempt will be made to fetch the sourceConfig immediately, as we assume (or the default behaviour is) that the network is always available in core SDKs.
  • Try to enable and disable connection multiple times, but sourceConfig will only be fetched once.

Log:

SourceConfig is fetched successfully: SourceConfig(source=RudderServerConfigSource(sourceId=......

Breaking Changes

Maintainers Checklist

  • The code has been reviewed.
  • CI tests have passed.
  • All necessary documentation has been updated.

Screenshots (if applicable)

Additional Context

@1abhishekpandey 1abhishekpandey self-assigned this Jan 14, 2025
@1abhishekpandey 1abhishekpandey marked this pull request as ready for review January 14, 2025 22:11
Copy link
Collaborator

@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.

Great effort!! 🚀

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.

2 participants