optimizely / swift-sdk

Swift SDK for Optimizely Feature Experimentation and Optimizely Full Stack (legacy)
https://www.optimizely.com/products/full-stack/
Apache License 2.0
21 stars 30 forks source link

[ENHANCEMENT] featureFlagKeyInvalid but for featureFlags #552

Closed miquelalvarado closed 4 months ago

miquelalvarado commented 4 months ago

Description

Right now we have not an easy way to know if a feature flag key is invalid (not present in the datafile). In the case of the activate method signature we can see that it can throw and one of its possible exceptions is experimentKeyInvalid which serves exactly to that purpose but for experiments. My suggestion is to provide with the very same functionality but for feature flags.

Right now we can workaround it by doing optimizelyClient.getOptimizelyConfig().featuresMap[feature.rawValue] but it can be VERY slow as getOptimizelyConfig parses all the information each time is called.

I could do a PR if you want.

Benefits

Would be a fast way for clients to provide with default values for feature flags even when those are not yet created in optimizely.

Detail

No response

Examples

No response

Risks/Downsides

The only downside is that by doing it throwable we will force any client integrating the sdk to modify their current implementation to handle any possible exception but on the other hand we would normalize both experiments and feature flags APIs.

muzahidul-opti commented 4 months ago

Hi @miquelalvarado thanks for your feedback. We will get back to you soon.

muzahidul-opti commented 4 months ago

Hi @miquelalvarado we would request you to use our decide api which is available in our latest release.

public func decide(key: String,  options: [OptimizelyDecideOption]? = nil) -> OptimizelyDecision

This will return an object to you with appropriate reasons if the flag key is invalid.

muzahidul-opti commented 4 months ago

Hi @miquelalvarado I am going to close the issue. If you have any concerns, then please feel free to contact us.