Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
---
title: OpenFeature Provider for Android SDK
sidebar_label: Android OpenFeature Provider
sidebar_position: 1
description: Integrate OpenFeature with Harness FME in your Android applications to evaluate feature flags, manage contexts, and track events using a standardized SDK.
---

## Overview

The <Tooltip id="fme.openfeature.provider">Android OpenFeature Provider</Tooltip> allows your Android applications to integrate with Harness FME using a standardized, vendor-agnostic feature flagging API. This provider implements the OpenFeature specification and bridges the OpenFeature SDK with the Harness FME Android SDK.

This page walks you through installing, configuring, and using the Android OpenFeature provider to evaluate <Tooltip id="fme.openfeature.feature-flag">feature flags</Tooltip> in your Android applications.

### Prerequisites

Before you begin, ensure you have the following:

- A valid [Harness FME SDK key](/docs/feature-management-experimentation/sdks-and-infrastructure/#api-keys) for your project
- An Android project targeting API Level 21 (Android 5.0 Lollipop) or later
- Access to your project's `build.gradle` or `build.gradle.kts` file to add the provider dependency

### Version compatibility

| Component | Minimum Version |
| --------------------------------- | ----------------------------------- |
| Android | API Level 21 (Android 5.0 Lollipop) |
| `split-openfeature-provider-android` | ≥ 1.0.0 |
| OpenFeature Kotlin SDK | ≥ 1.0.0 |

## Install the provider and dependencies

Add the Harness FME OpenFeature provider dependency to your application's `build.gradle.kts` file.

```kotlin
dependencies {
implementation("io.split.openfeature:split-openfeature-android:1.0.0")
}
```

Or, if you're using the Groovy DSL (`build.gradle`):

```groovy
dependencies {
implementation 'io.split.openfeature:split-openfeature-android:1.0.0'
}
```

## Initialize the provider

The FME OpenFeature provider requires an Android application `Context` (for SDK initialization) and your Harness FME SDK Key.

```kotlin
import dev.openfeature.kotlin.sdk.OpenFeatureAPI
import dev.openfeature.kotlin.sdk.ImmutableContext
import io.split.openfeature.android.provider.SplitProvider

// Create provider configuration
val config = SplitProvider.Config(
applicationContext = applicationContext,
sdkKey = "YOUR_SDK_KEY"
)

// Create the FME provider
val provider = SplitProvider(config = config)

// Set the provider with an initial context containing a targeting key
val initialContext = ImmutableContext(targetingKey = "user-123")
OpenFeatureAPI.setProvider(provider, initialContext = initialContext)

// Get a client and evaluate flags
val client = OpenFeatureAPI.getClient()
val showNewFeature = client.getBooleanValue("new-feature", false)
```

## Construct an evaluation context

To evaluate flags, you'll need to provide an <Tooltip id="fme.openfeature.evaluation-context">evaluation context</Tooltip> with a <Tooltip id="fme.openfeature.targeting-key">targeting key</Tooltip>. The evaluation context passes targeting information such as user IDs, email addresses, or plan types for flag targeting.

For example:

```kotlin
val context = ImmutableContext(
targetingKey = "user-123",
attributes = mapOf(
"email" to Value.String("[email protected]"),
"age" to Value.Integer(30),
"plan" to Value.String("premium")
)
)

val client = OpenFeatureAPI.getClient()
val result = client.getBooleanDetails("premium-feature", false, context)
```

To set a targeting key during initialization:

```kotlin
val initialContext = ImmutableContext(targetingKey = "user-123")
OpenFeatureAPI.setProvider(provider, initialContext = initialContext)
```

To change a targeting key at runtime:

```kotlin
val newContext = ImmutableContext(targetingKey = "user-456")
OpenFeatureAPI.setEvaluationContext(newContext)
```

## Observe provider events

The FME OpenFeature provider emits <Tooltip id="fme.openfeature.events">events</Tooltip> when provider state changes (for example, when flags update, configuration changes, or errors) occur. You can observe these events to react dynamically in your application.

```kotlin
import dev.openfeature.kotlin.sdk.events.OpenFeatureProviderEvents
import kotlinx.coroutines.launch

// Observe provider events
lifecycleScope.launch {
provider.observe().collect { event ->
when (event) {
is OpenFeatureProviderEvents.ProviderReady -> {
// Provider is ready to evaluate flags
Log.d("Split", "Provider is ready")
}
is OpenFeatureProviderEvents.ProviderConfigurationChanged -> {
// Flag configuration has been updated
Log.d("Split", "Configuration changed")
}
is OpenFeatureProviderEvents.ProviderStale -> {
// Provider is serving cached data
Log.d("Split", "Provider is stale")
}
is OpenFeatureProviderEvents.ProviderError -> {
// An error occurred
Log.e("Split", "Provider error: ${event.error}")
}
}
}
}
```

## Track events

The FME OpenFeature provider supports tracking events such as user actions or conversions. To enable event tracking, set a [`TrafficType`](/docs/feature-management-experimentation/management-and-administration/fme-settings/traffic-types/) in the evaluation context.

```kotlin
// Set context with trafficType
val context = ImmutableContext(targetingKey = "user-123")
.withTrafficType("user")

OpenFeatureAPI.setEvaluationContext(context)

// Track an event
val client = OpenFeatureAPI.getClient()
client.track("button_clicked")

// Track with a value
client.track(
"purchase_completed",
TrackingEventDetails(value = 99.99)
)

// Track with properties
client.track(
"page_viewed",
TrackingEventDetails(
structure = ImmutableStructure(
mapOf(
"page" to Value.String("home"),
"referrer" to Value.String("google")
)
)
)
)
```

For more information, see the [Harness FME Android OpenFeature Provider GitHub repository](https://github.com/splitio/split-openfeature-provider-android/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: OpenFeature Providers
id: index
slug: /feature-management-experimentation/sdks-and-infrastructure/openfeature
sidebar_position: 1
description: Learn about using Harness OpenFeature providers for feature management.
---

## Overview

[OpenFeature](https://openfeature.dev/docs/reference/intro) offers a standardized, vendor-agnostic SDK for feature flagging that can integrate with a variety of third-party providers. Whether you're using an open-source or commercial solution, self-hosted or cloud-hosted, OpenFeature gives developers a unified API for consistent feature flag evaluation.

OpenFeature SDKs provide flexible abstractions that make it easy to integrate feature flags into any application. Within your application, the feature flagging client uses the OpenFeature SDK to evaluate <Tooltip id="fme.openfeature.feature-flag">feature flags</Tooltip> through the <Tooltip id="fme.openfeature.evaluation-api">Evaluation API</Tooltip>.

Each flag evaluation passes an <Tooltip id="fme.openfeature.evaluation-context">evaluation context</Tooltip>, which provides relevant data about the application or user.

```mermaid
flowchart LR
%% Outer app box
subgraph YourApp["Your App"]
style YourApp fill:#D0E4FF,stroke:#0000FF,stroke-width:2px

%% Feature Flagging Client (yellow dotted box)
subgraph FeatureFlagClient["Feature Flagging Client"]
style FeatureFlagClient stroke:#FFD700,stroke-dasharray: 5 5

%% Puzzle piece: OpenFeature SDK
subgraph OpenFeatureSDK["OpenFeature SDK"]
style OpenFeatureSDK fill:#FFFF99,stroke:#FFD700

%% Flag Evaluation API inside SDK
FlagEvalAPI["Flag Evaluation API"]
end

%% OpenFeature Provider in second half of puzzle piece
OpenFeatureProvider["Harness FME <br> OpenFeature Provider"]
end

%% Arrows from Flag Eval through Eval Context directly into FlagEvalAPI
FlagEval1["Flag Eval"] --> EvalCtx1["Eval Context"] --> FlagEvalAPI
FlagEval2["Flag Eval"] --> EvalCtx2["Eval Context"] --> FlagEvalAPI
end

%% External Harness FME Service in cloud
HarnessFME["Harness FME Service"]:::cloudStyle

%% Bidirectional arrow between OpenFeature Provider and Harness FME
OpenFeatureProvider <--> HarnessFME

%% Styling for cloud
classDef cloudStyle fill:#A4E5A4,stroke:#2E8B57,stroke-width:2px,shape:cloud
```

<br />

The <Tooltip id="fme.openfeature.provider">OpenFeature Provider</Tooltip> wraps the Harness FME SDK, bridging the OpenFeature SDK with the Harness Feature Management & Experimentation (FME) service. The provider maps OpenFeature's standardized interface to the FME SDK, which handles communication with Harness services to evaluate feature flags and retrieve configuration updates.

## Use OpenFeature SDKs

Harness FME offers official OpenFeature providers for the following SDKs.

import { Section, openfeatureSDKs } from '@site/src/components/Docs/data/fmeOpenfeature';

<Section items={openfeatureSDKs} />

You can use these providers instead of the Harness FME SDK in your application.
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
---
title: OpenFeature Provider for Java SDK
sidebar_label: Java OpenFeature Provider
sidebar_position: 3
description: Integrate OpenFeature with Harness FME in your Java applications to evaluate feature flags, manage contexts, and track events using a standardized SDK.
---

## Overview

The <Tooltip id="fme.openfeature.provider">Java OpenFeature Provider</Tooltip> allows your Java applications to integrate with Harness FME using a standardized, vendor-agnostic feature flagging API. This provider implements the OpenFeature specification and bridges the OpenFeature SDK with the Harness FME Java SDK.

This page walks you through installing, configuring, and using the Java OpenFeature provider to evaluate <Tooltip id="fme.openfeature.feature-flag">feature flags</Tooltip> in your Java applications.

### Prerequisites

Before you begin, ensure you have the following:

- A valid [Harness FME SDK key](/docs/feature-management-experimentation/sdks-and-infrastructure/#api-keys) for your project
- A Java environment running version 11 or later
- Access to your Maven build configuration

### Version compatibility

| Component | Minimum Version |
| ---------------------------------------- | ---------------- |
| Java | 11+ |
| `split-openfeature-provider-java` | ≥ 1.2.1 |
| OpenFeature Java SDK | ≥ 1.0.0 |

## Install the provider and dependencies

Add the Harness FME OpenFeature provider dependency to your Maven build configuration.

```java
<dependency>
<groupId>io.split.openfeature</groupId>
<artifactId>split-openfeature-provider</artifactId>
<version>1.2.1</version>
</dependency>
```

## Initialize the provider

You can instantiate and register the provider using your Harness FME SDK key.

```java
import dev.openfeature.sdk.OpenFeatureAPI;
import io.split.openfeature.SplitProvider;

OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProviderAndWait(new SplitProvider("<YOUR_API_KEY>"));
```

Alternatively, if you want more control or need [advanced initialization](/docs/feature-management-experimentation/sdks-and-infrastructure/server-side-sdks/java-sdk/#configuration), you can create a `SplitClient` and provide it directly:

```java
import dev.openfeature.sdk.OpenFeatureAPI;
import io.split.openfeature.SplitProvider;
import io.split.client.SplitClient;
import io.split.client.SplitClientConfig;
import io.split.client.SplitFactoryBuilder;

OpenFeatureAPI api = OpenFeatureAPI.getInstance();


SplitClientConfig config = SplitClientConfig.builder()
.setBlockUntilReadyTimeout(10000)
.build();
SplitClient splitClient = SplitFactoryBuilder.build("<YOUR_API_KEY>", config).client();
api.setProviderAndWait(new SplitProvider(splitClient));
```

## Construct an evaluation context

To evaluate flags, you'll need to provide an <Tooltip id="fme.openfeature.evaluation-context">evaluation context</Tooltip> with a <Tooltip id="fme.openfeature.targeting-key">targeting key</Tooltip>. The evaluation context passes targeting information such as user IDs, email addresses, or plan types for flag targeting.

For example:

```java
Client client = api.getClient("CLIENT_NAME");

EvaluationContext context = new MutableContext("<TARGETING_KEY>");
Boolean boolValue = client.getBooleanValue("boolFlag", false, context);
```

If the same targeting key is reused across evaluations, set the context at the client or API level:

```java
EvaluationContext context = new MutableContext("<TARGETING_KEY>");
client.setEvaluationContext(context)
```

Or globally:

```java
EvaluationContext context = new MutableContext("<TARGETING_KEY>");
OpenFeatureAPI.getInstance().setEvaluationContext(context)
```

Once the context is set at the client or API level, you don’t need to provide it for each evaluation.

## Evaluate with details

Use the `get*Details(...)` APIs to get flag values and metadata (such as variant, reason, error code, and configuration). The FME treatment configuration is returned as a raw JSON string under `flagMetadata["config"]`.

For example:

```java
// boolean/string/number/object all have *Details variants:
FlagEvaluationDetails<String> details =
client.getStringDetails("my-flag", "fallback", ctx);

String jsonConfig = details.getFlagMetadata().getString("config"); // ← Split treatment config
```

## Track events

The FME OpenFeature provider supports tracking user actions or conversion <Tooltip id="fme.openfeature.events">events</Tooltip> directly from your Java application.

To enable event tracking, your evaluation context must include the following:

- A non-empty `targetingKey`
- A [`trafficType`](/docs/feature-management-experimentation/management-and-administration/fme-settings/traffic-types/) (for example, `"user"` or `"account"`)
- A non-blank event name

Optionally, you can include a numeric value and additional event properties. For more information, see [Sending Events](https://developer.harness.io/docs/feature-management-experimentation/api/events/#event-record-fields).

For example:

```java
MutableContext ctx = new MutableContext("user-123");
ctx.add("trafficType", new Value("user"));

TrackingEventDetails details = new MutableTrackingEventDetails(19.99)
.add("plan", new Value("pro"))
.add("coupon", new Value("WELCOME10"));

client.track("checkout.completed", ctx, details);
```

For more information, see the [Harness FME Java OpenFeature Provider GitHub repository](https://github.com/splitio/split-openfeature-provider-java).
Loading