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

Bug: Product config function fetchAndActivate is not working as expected. #127

Closed
SuhasTS opened this issue Dec 1, 2020 · 6 comments
Closed
Labels
pending release Will be released in the next release

Comments

@SuhasTS
Copy link

SuhasTS commented Dec 1, 2020

Function fetchAndActivate() in class CTProductConfigController is fetching the new values but failing to activate the same in some scenarios.

fun setup(context: Context) {
        Log.d("ProductExperience", "setup: ")
        val clevertapApi = CleverTapAPI.getDefaultInstance(context) ?: return
        val productConfigController = clevertapApi.productConfig()
        productConfigController.setDefaults(R.xml.product_experience_defaults)
        clevertapApi.setCTProductConfigListener(object : CTProductConfigListener {
            override fun onActivated() {
                Log.d("ProductExperience", "onActivated: ${productConfigController.getString("Debug")}")
            }

            override fun onFetched() {
                Log.d("ProductExperience", "onFetched: ${productConfigController.getString("Debug")}")
            }

            override fun onInit() {
                Log.d("ProductExperience", "onInit: ${productConfigController.getString("Debug")}")
                productConfigController.activate()
                productConfigController.fetchAndActivate()
            }
        })
    }

Logs on running the above function

D/ProductExperience: setup: 
D/ProductExperience: onInit: 
D/ProductExperience: onActivated: Default value in xml
D/ProductExperience: onInit: Default value in xml
D/ProductExperience: onActivated: Default value in xml
D/ProductExperience: onFetched: Default value in XML  //onactivated callback is missing after this
SuhasTS added a commit to SuhasTS/clevertap-android-sdk that referenced this issue Dec 1, 2020
@kratuldev
Copy link
Contributor

@SuhasTS Thanks for the time & effort to raise a fix for this.

Before going ahead with the PR, Can you please explain the scenario in which it's failing & the solution you have proposed will work to handle the scenario?

@SuhasTS
Copy link
Author

SuhasTS commented Dec 3, 2020

The sample function that I have shared is the scenario where it fails.
Basically when you call fetchAndActivate and previously called activate function is completed after that(activate function is asynchronous) the variable isFetchAndActivating is reset to false as a result, it only fetches the new values but never activates them.
The PR which I have raised resolves this issue.

@kratuldev
Copy link
Contributor

@SuhasTS As per my understanding , you are calling activate() & fetchAndActivate() method one after another in a sequence. So the isFetchAndActivating = true is getting overridden.

Please confirm.

@SuhasTS
Copy link
Author

SuhasTS commented Dec 3, 2020

Yes.

@kratuldev
Copy link
Contributor

@SuhasTS Thanks for confirming.

We will including the fix in our next planned release.
Will keep you informed.

@darshanclevertap darshanclevertap added the pending release Will be released in the next release label Dec 16, 2020
@kratuldev
Copy link
Contributor

@SuhasTS we have fixed this issue with latest release(4.0.3).

Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending release Will be released in the next release
Projects
None yet
Development

No branches or pull requests

3 participants