Skip to content

Conversation

@jaeopt
Copy link
Contributor

@jaeopt jaeopt commented Oct 23, 2025

Summary

This pull request introduces significant enhancements to the Android SDK, primarily by adding support for a new Contextual Multi-Armed Bandit (CMAB) service and improving user context handling for decision APIs. The main changes include the introduction of the OptimizelyUserContextAndroid class for better synchronous and asynchronous decision support, integration of CMAB service components into the SDK, and updates to the builder and manager classes to support these new features.

User Context and Decision API Improvements:

  • Introduced a new OptimizelyUserContextAndroid class, extending OptimizelyUserContext to provide both synchronous and asynchronous decision APIs, ensuring backward compatibility and improved usability for Android clients. (android-sdk/src/main/java/com/optimizely/ab/android/sdk/OptimizelyUserContextAndroid.java)
  • Updated the OptimizelyClient class to return OptimizelyUserContextAndroid instances from all createUserContext methods, with improved null checks and logging for invalid parameters. (android-sdk/src/main/java/com/optimizely/ab/android/sdk/OptimizelyClient.java)

CMAB Service Integration:

  • Added CMAB service support to OptimizelyManager, including new fields, constructor parameters, and wiring through the builder pattern. This enables configuration and use of the CMAB service within the SDK. (android-sdk/src/main/java/com/optimizely/ab/android/sdk/OptimizelyManager.java) [1] [2] [3] [4] [5] [6]
  • Added new builder options for CMAB client and cache configuration, with sensible defaults for cache size and timeout. (android-sdk/src/main/java/com/optimizely/ab/android/sdk/OptimizelyManager.java) [1] [2]

New CMAB Client Implementation:

  • Introduced the CMABClient class, which handles HTTP requests to the CMAB prediction endpoint, including request/response handling, error management, and exponential backoff for retries. (android-sdk/src/main/java/com/optimizely/ab/android/sdk/cmab/CMABClient.kt)

Other Minor Changes:

  • Added an import for DefaultPersistenceDelegate (appears unused and may be cleanup in a later revision). (android-sdk/src/main/java/com/optimizely/ab/android/sdk/OptimizelyManager.java)

These changes collectively enhance the SDK's flexibility and robustness, especially around user context management and support for advanced decisioning features like CMAB."

Test plan

Issues

  • "FSSDK-11136

Copy link
Contributor

@muzahidul-opti muzahidul-opti left a comment

Choose a reason for hiding this comment

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

Changes look good to me. I really like OptimizelyUserContextAndroid subclassing. It simplifies the async approach.
I made a couple of questions for clarifications.

}

public Builder withCmabClient(CmabClient cmabClient) {
this.cmabClient = cmabClient;
Copy link
Contributor

Choose a reason for hiding this comment

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

For swift CmabClient is internal, here it is public, why this difference?

import java.net.HttpURLConnection
import java.net.URL

@VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for clarification:
Why can't we use the java client here, what was the challenge?

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 this pull request may close these issues.

2 participants