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

chore: improve kotlin sdk #99

Merged
merged 31 commits into from
Jan 9, 2025

Conversation

1abhishekpandey
Copy link
Contributor

@1abhishekpandey 1abhishekpandey commented Jan 3, 2025

Description

  • In this PR, we have:
    • Removed the unused code.
    • Improved a few comments.
    • Decoupled sample app custom plugin by removing its dependency on the Kotlin SDK's Utils methods. This ensures we can change our SDK Utils method freely without bothering about the need to ensure any kind of backward compatibility.
    • Refactored a couple of test classes.
    • Restricted the visibility of methods/classes by making them internal/private or adding @InternalRudderApi annotation. This enhances readability and makes the intention of the method/variable/classes clear. It also safeguards them from future changes (e.g., suppose someone modified the internal class to public and forgot to restrict the internal methods modifier. This might cause some issues). It also makes our SDK Utils method intention clear i.e., any user or custom plugins shouldn't use them and SDK is free to change them at any point in time.

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

Improve comments

  • Analytics, Configuration, BasicStorage

Remove stale methods

  • SharedPrefsStore - Removed private delete method and float support, as both of them are not utilised anywhere.
  • CheckBuildVersionUseCase
  • UnsupportedTypeException.kt
  • JSONUtils.kt - Remove JsonObjectBuilder.putAll, as it is no longer required, after replacing its usage with mergeWithHigherPriorityTo.

Change modifier - Make it internal/private or add @InternalRudderApi annotation

  • AndroidStorage
  • ActivityLifecycleManagementPlugin.kt, ProcessLifecycleManagementPlugin.kt, NavControllerActivityObserver.kt, SessionTrackingPlugin.kt, CheckBuildVersionUseCase.kt, AnalyticsConfiguration.kt, HttpClientImpl.kt, Platform.kt, EventQueue.kt, FlowState.kt, BasicStorage.kt, EventBatchFileManager.kt, PropertiesFile.kt, AnalyticsUtils.kt, Base64.kt, DateTimeUtils.kt, JSONUtils.kt, JsonSentAtUpdater.kt, StringUtils.kt and HttpClientImplProvider.kt.

Decouple sample app custom plugins from the Kotlin SDK Utils method

  • Decoupled AndroidAdvertisingIdPlugin.kt by refactoring the code so that it is not dependent on the Kotlin SDK Utils method. It'll ensure that we can modify our Kotlin SDK Utils method as and when needed.

Refactor test classes

  • DeviceInfoPluginTest.kt - Replace the use of putAll with mergeWithHigherPriorityTo.
  • HttpClientImplProvider.kt - Change the modifier of the class to internal, as the compiler was giving a warning that we are exposing internal methods.

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 app and verify everything is working fine and events are made correctly.

Breaking Changes

Maintainers Checklist

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

Screenshots (if applicable)

Additional Context

I've skipped a few classes e.g., PluginChain related classes for now.

@1abhishekpandey 1abhishekpandey self-assigned this Jan 3, 2025
Note: This is just to improve the readability. As the class is internal, we are not really changing anything.
Note: This is just to improve the readability. As the class is internal, we are not really changing anything.
Note: This is just to improve the readability. As the class is internal, we are not really changing anything.
Note: This is just to improve the readability. As the class is internal, we are not really changing anything.
By either marking method as internal or adding InternalRudderApi annotation
By either marking method as internal or adding InternalRudderApi annotation
By either marking method as internal or adding InternalRudderApi annotation
By either marking method as internal or adding InternalRudderApi annotation
Currently, SDK cannot change it's util method, if user get dependent on this.
By either marking method as internal or adding InternalRudderApi annotation
By either marking method as internal or adding InternalRudderApi annotation
By either marking method as internal or adding InternalRudderApi annotation
By either marking method as internal or adding InternalRudderApi annotation
As this class is not used anywhere.
By either marking method as internal or adding InternalRudderApi annotation
By either marking method as internal or adding InternalRudderApi annotation
By either marking method as internal or adding InternalRudderApi annotation
… class

By either marking method as internal or adding InternalRudderApi annotation
@1abhishekpandey 1abhishekpandey marked this pull request as ready for review January 7, 2025 07:44
@1abhishekpandey 1abhishekpandey merged commit 7a2098f into develop Jan 9, 2025
2 checks passed
@1abhishekpandey 1abhishekpandey deleted the chore/sdk-2758-improve-kotlin-sdk branch January 9, 2025 15:58
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.

3 participants