Skip to content

feat(ATS): update OptimizelyManager/OptimizelyClient for ODP integration #444

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

Merged
merged 12 commits into from
Jan 17, 2023

Conversation

jaeopt
Copy link
Contributor

@jaeopt jaeopt commented Jan 9, 2023

Summary

Extends top level (OptimizelyManager/OptimizelyClient) to provide public APIs and connect to the core ATS features provided by the integrated Java-SDK.

Add new APIs:

  • OptimizelyClient.createUserContext() without userId
  • OptimizelyClient.sendOdpEvent()

ODP Configuration (OptimizelyManager.Builder)

  • SegmentCache configuration
  • ODPClient timeout configuration
  • Disable ODP

Test plan

  • Add new unit tests covering new APIs

Issues

  • FSSDK-8549
  • FSSDK-8695

Copy link
Contributor

@mnoman09 mnoman09 left a comment

Choose a reason for hiding this comment

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

Overall looks good. Added few comments. I am not seeing custom cache support in this PR, so are we going to add it in a separate PR?


@Nullable private OptimizelyStartListener optimizelyStartListener;

@Nullable private final List<OptimizelyDecideOption> defaultDecideOptions;
@NonNull private final List<OptimizelyDecideOption> defaultDecideOptions;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we change it to Nonnull, because I am still seeing it nullable at other places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A good catch. I might be confused. It has been restored back to Nullable.

@@ -724,6 +741,13 @@ public static class Builder {
@Nullable private DatafileConfig datafileConfig = null;
@Nullable private List<OptimizelyDecideOption> defaultDecideOptions = null;

private long odpSegmentCacheSize = 100L;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think instead of long we should use int data type because eventually we are parsing it to int. Same goes for odpSegmentCacheTimeoutInSecs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed all odp numbers to int.

}

@Test
public void testBuildWithODP_defautSegmentFetchTimeout() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void testBuildWithODP_defautSegmentFetchTimeout() throws Exception {
public void testBuildWithODP_defaultSegmentFetchTimeout() throws Exception {

}

@Test
public void testBuildWithODP_defaultCache() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void testBuildWithODP_defaultCache() throws Exception {
public void testBuildWithODP_defaultCacheSize() throws Exception {

@@ -191,4 +228,145 @@ public void testBuildWithDatafileDownloadInterval_workerCancelledWhenNoIntervalP
verify(mockDatafileHandler, never()).startBackgroundUpdates(any(), any(), any(), any());
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Update the header of this file.

@@ -79,7 +79,7 @@ open class ODPSegmentClient(private val client: Client, private val logger: Logg
}

companion object {
// easy way to set the connection timeout
// configurable connection timeout
var CONNECTION_TIMEOUT = 10 * 1000
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add comment here to show its unit, "ms".

/*
OptimizelyManager is initialized with an OptimizelyClient with a null optimizely property:
https://github.com/optimizely/android-sdk/blob/master/android-sdk/src/main/java/com/optimizely/ab/android/sdk/OptimizelyManager.java#L63
optimizely will remain null until OptimizelyManager#initialize has been called, so isValid checks for that. Otherwise apps would crash if
the public methods here were called before initialize.
So, we start with an empty map of default attributes until the manager is initialized.
*/

if (isValid()) {
if (this.vuid != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we only going to trigger sendOdpEvent for client_intialized when vuid is given instead of user id or is it for both cases? Also if the vuid will be inserted by java sdk then what will this check ensure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A good catch. I remove vuid null checking.

@jaeopt
Copy link
Contributor Author

jaeopt commented Jan 12, 2023

Overall looks good. Added few comments. I am not seeing custom cache support in this PR, so are we going to add it in a separate PR?

@mnoman09 it's not expected that android-sdk clients will customize the cache (other than size and timeout), so not supported until we see demands.

@jaeopt jaeopt requested a review from mnoman09 January 12, 2023 19:27
@jaeopt
Copy link
Contributor Author

jaeopt commented Jan 12, 2023

@mnoman09 all suggestions addressed. Please review again.

Copy link
Contributor

@mnoman09 mnoman09 left a comment

Choose a reason for hiding this comment

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

lgtm.

@jaeopt jaeopt merged commit 2b0dc02 into master Jan 17, 2023
@jaeopt jaeopt deleted the jae/odp-integration branch January 17, 2023 17:01
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.

3 participants