optimizely / android-sdk

Android SDK for Optimizely Feature Experimentation and Optimizely Full Stack (legacy)
https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/android-sdk
Apache License 2.0
55 stars 39 forks source link

`updateConfigOnNewDatafile` does nothing #420

Closed schmecs closed 2 years ago

schmecs commented 2 years ago

https://github.com/optimizely/android-sdk/blob/f11ed5bfc59d23ed3a9745603076de79fa4a12a8/datafile-handler/src/main/java/com/optimizely/ab/android/datafile_handler/DatafileHandler.java#L55

In OptimizelyManager, the initialize method states:

updateConfigOnNewDatafile – When a new datafile is fetched from the server in the background thread, the SDK will be updated with the new datafile immediately if this value is set to true. When it's set to false (default), the new datafile is cached and will be used when the SDK is started again.

As you can see in the DatafileHandler method, that boolean actually appears to be unused. I've confirmed through testing that the default is to apply the config immediately. This is actually the behavior we want in our app, but we are not setting updateConfigOnNewDatafile to true. It seems like it's not currently possible to delay application of a new datafile until the next session.

Edit: I see that this flag is used appropriately in DefaultDatafileHandler, but I can confirm that when we initialize without setting it, the updated config is applied immediately, so it seems like this default is not automatically applied. It appears we might need to add .withDatafileHandler(DefaultDatafileHandler()) to our initialize call. Does that sound right?

jaeopt commented 2 years ago

@schmecs Correct, the flag is used in the override method of DefaultDatafileHandler. DefaultDatafileHandler is used when you do not provide a custom one, so it's not required to add the default one. If you enable periodic datafile updates (.withDatafileDownloadInterval(TimeUnit.MINUTES.toSeconds(15)), that can be another source of enabling the flag automatically.

schmecs commented 2 years ago

Ah -- that explains it. We're using .withDatafileDownloadInterval which must be enabling immediate application. Thanks for the quick explanation!