Skip to content

Commit

Permalink
docs: update android variation details
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Yuichi Okimoto <[email protected]>
  • Loading branch information
cre8ivejp committed Oct 18, 2024
1 parent b2e7fcd commit f335e9a
Showing 1 changed file with 80 additions and 45 deletions.
125 changes: 80 additions & 45 deletions docs/sdk/client-side/android/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,86 @@ fun intVariation(featureId: String, defaultValue: Int): Int

fun doubleVariation(featureId: String, defaultValue: Double): Double

fun jsonVariation(featureId: String, defaultValue: JSONObject): JSONObject
fun objectVariation(featureId: String, defaultValue: BKTValue): BKTValue
```

</TabItem>
</Tabs>

### Getting evaluation details

The following methods will return the **evaluation details** for a specific feature flag or will return **null** if the feature flag is missing in the SDK's cache.

This is useful if you use another A/B Test solution with Bucketeer and need to know the variation name, reason, and other information.


#### Interface

<Tabs>
<TabItem value="kt" label="Kotlin">

```kotlin showLineNumbers
fun boolVariationDetails(
featureId: String,
defaultValue: Boolean,
): BKTEvaluationDetails<Boolean>

fun stringVariationDetails(
featureId: String,
defaultValue: String,
): BKTEvaluationDetails<String>

fun intVariationDetails(
featureId: String,
defaultValue: Int,
): BKTEvaluationDetails<Int>

fun doubleVariationDetails(
featureId: String,
defaultValue: Double,
): BKTEvaluationDetails<Double>

fun objectVariationDetails(
featureId: String,
defaultValue: BKTValue,
): BKTEvaluationDetails<BKTValue>
```

</TabItem>
</Tabs>

#### Object

<Tabs>
<TabItem value="kt" label="Kotlin">

```kotlin showLineNumbers
data class BKTEvaluationDetails<T>(
val featureId: String,
val featureVersion: Int,
val userId: String,
val variationId: String,
val variationName: String,
val variationValue: T,
val reason: Reason,
)
```

</TabItem>
</Tabs>

#### Usage

<Tabs>
<TabItem value="kt" label="Kotlin">

```kotlin showLineNumbers
val showNewFeature = client.boolVariationDetails("YOUR_FEATURE_FLAG_ID", false)
if (showNewFeature.variationValue) {
// The Application code to show the new feature
} else {
// The code to run when the feature is off
}
```

</TabItem>
Expand Down Expand Up @@ -527,50 +606,6 @@ val user = client.currentUser()
</TabItem>
</Tabs>

### Getting evaluation details

This method will return the **evaluation details** for a specific feature flag or will return **null** if the feature flag is missing in the SDK's cache.

This is useful if you use another A/B Test solution with Bucketeer and need to know the variation name, reason, and other information.

<details>
<summary><strong>Evaluation details</strong></summary>
<Tabs>
<TabItem value="kt" label="Kotlin">

```kotlin showLineNumbers
data class BKTEvaluation(
var id: String,
val featureId: String,
val featureVersion: Int,
val userId: String,
val variationId: String,
val variationName: String,
val variationValue: String,
val reason: Reason,
)
```

</TabItem>
</Tabs>
</details>

:::caution

Do not call this method without calling the [Evaluating user method](#evaluating-user). The Evaluating user method must always be called because it generates analytics events that will be sent to the server.

:::

<Tabs>
<TabItem value="kt" label="Kotlin">

```kotlin showLineNumbers
val evaluationDetails = client.evaluationDetails("YOUR_FEATURE_FLAG_ID")
```

</TabItem>
</Tabs>


### Listening to evaluation updates

Expand Down

0 comments on commit f335e9a

Please sign in to comment.