Problem
When using SDK, control treatment is either always or very often returned from getTreatment
call.
Root Cause
When getTreatment
call returns control, this means either:
- The there is an issue with network connection to Split cloud and http calls are timing out. Enable the SDK debugging log file to verify if there are any network errors.
- The SDK is still downloading relevant feature flag definitions and Segments from Split cloud and still did not finish when
getTreatment
call is executed.
Solution
The 'control' treatment is most likely to return using the mobile SDKs; Javascript, Android and iOS. Simply because potentially the SDK runs on users' mobile devices which may have a slow network connection.
That is why for these SDKs getTreatment
should always be called when the SDK_READY events fires, which will ensure it's called after the SDK downloads all the information from Split cloud and avoid returning 'control' treatments.
client.on(client.Event.SDK_READY, function() {
var treatment = client.getTreatment("SPLIT_NAME");
if (treatment == "on") {
// insert code here to show on treatment
} else if (treatment == "off") {
// insert code here to show off treatment
} else {
// insert your control treatment code here
}
});
Comments
1 comment
I have also found that 'control' is returned when you request a split by a name that has no treatments - for example you have a staging and prod environment and haven't defined the treatments it in the prod environment.
Easily coded for as shown above, more likely to be an issue with multiple treatments where a switch statement is used but as long as a safe default is used, all is well.
Please sign in to leave a comment.