diff --git a/open-feature/sdk/src/main/scala/io/cardell/openfeature/EvaluationDetails.scala b/open-feature/sdk/src/main/scala/io/cardell/openfeature/EvaluationDetails.scala index abab4b2..9219894 100644 --- a/open-feature/sdk/src/main/scala/io/cardell/openfeature/EvaluationDetails.scala +++ b/open-feature/sdk/src/main/scala/io/cardell/openfeature/EvaluationDetails.scala @@ -23,7 +23,7 @@ object EvaluationDetails { flagKey = flagKey, value = resolution.value, errorCode = resolution.errorCode, - errorMessage = errorMessage.errorMessage, + errorMessage = resolution.errorMessage, reason = resolution.reason, variant = resolution.variant, metadata = resolution.metadata diff --git a/open-feature/sdk/src/main/scala/io/cardell/openfeature/FeatureClient.scala b/open-feature/sdk/src/main/scala/io/cardell/openfeature/FeatureClient.scala index 28e0424..0053f71 100644 --- a/open-feature/sdk/src/main/scala/io/cardell/openfeature/FeatureClient.scala +++ b/open-feature/sdk/src/main/scala/io/cardell/openfeature/FeatureClient.scala @@ -66,6 +66,22 @@ trait FeatureClient[F[_]] { options: EvaluationOptions ): F[String] + def getStringDetails( + flagKey: String, + default: String + ): F[EvaluationDetails[String]] + def getStringDetails( + flagKey: String, + default: String, + context: EvaluationContext + ): F[EvaluationDetails[String]] + def getStringDetails( + flagKey: String, + default: String, + context: EvaluationContext, + options: EvaluationOptions + ): F[EvaluationDetails[String]] + def getIntValue(flagKey: String, default: Int): F[Int] def getIntValue( flagKey: String, @@ -196,14 +212,32 @@ protected final class OpenFeatureClient[F[_]: Monad]( context: EvaluationContext, options: EvaluationOptions ): F[String] = - provider - .resolveStringValue( - flagKey, - default, - clientEvaluationContext ++ context - ) + getStringDetails(flagKey, default, context, EvaluationOptions.Defaults) .map(_.value) + override def getStringDetails( + flagKey: String, + default: String + ): F[EvaluationDetails[String]] = + getStringDetails(flagKey, default, EvaluationContext.empty) + + override def getStringDetails( + flagKey: String, + default: String, + context: EvaluationContext + ): F[EvaluationDetails[String]] = + getStringDetails(flagKey, default, context, EvaluationOptions.Defaults) + + override def getStringDetails( + flagKey: String, + default: String, + context: EvaluationContext, + options: EvaluationOptions + ): F[EvaluationDetails[String]] = + provider + .resolveStringValue(flagKey, default, clientEvaluationContext ++ context) + .map(EvaluationDetails[String](flagKey, _)) + override def getIntValue(flagKey: String, default: Int): F[Int] = getIntValue(flagKey, default, EvaluationContext.empty)