This has been requested via FS swift-sdk github issues (https://github.com/optimizely/swift-sdk/issues/291)
Currently SDK provides an error experimentKeyInvalid
which says "Experiment key ((key)) is not in datafile. It is either invalid, paused, or archived." which means that there is no way to distinguish why the key is not in a data file.
Use-case: phasing out old feature flags. With a separate error (or any other form of feedback) for archived feature switches we would be able to code the app the way that for archived flags we consider them enabled and for other kind of errors we consider them disabled (which is a default for every flag). This way we can archive flags without risk for users to go back to old experiences if they are using versions of the app which still rely on the archived feature flag.
Here is a code snippet from our project that we would be hoping to write with this:
@ABTestVariant(key: "some_feature")
let booleanFlag: Bool
struct ABTestVariant {
init(...) {
self.value = { (client: OptimizelyClient) in
try {
return client.isFeatureEnabled() // for active feature switch get the value from a client } catch OptimizelyError.archived {
return true // consider all archived experiment as finished and fully rolled out for all versions, including old versions of the app } catch {
return false // in case of any other error consider feature disabled for all versions of the app }
}
}
}