Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 9 additions & 7 deletions docs/reference/sdks/client/kotlin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This content has been automatically generated from kotlin-sdk.
Edits should be made here: https://github.com/open-feature/kotlin-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:16 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down Expand Up @@ -100,7 +100,7 @@ coroutineScope.launch(Dispatchers.Default) {
val client = OpenFeatureAPI.getClient()

// get a bool flag value
client.getBooleanValue("boolFlag", default = false)
client.getBooleanValue("boolFlag", defaultValue = false)
}
```

Expand Down Expand Up @@ -227,16 +227,16 @@ Please refer to the documentation of the provider you're using to see what event
Example usage:
```kotlin
viewModelScope.launch {
OpenFeatureAPI.observe().collect {
OpenFeatureAPI.observe<OpenFeatureProviderEvents>().collect {
println(">> Provider event received")
}
}

viewModelScope.launch {
OpenFeatureAPI.setProviderAndWait(
MyFeatureProvider(),
Dispatchers.Default,
myEvaluationContext
myEvaluationContext,
Dispatchers.Default
)
}
```
Expand All @@ -257,7 +257,9 @@ The OpenFeature API provides a close function to perform a cleanup of the regist
This should only be called when your application is in the process of shutting down.

```kotlin
OpenFeatureAPI.shutdown()
coroutineScope.launch {
OpenFeatureAPI.shutdown()
}
```
## Sample app

Expand All @@ -276,7 +278,7 @@ To develop a provider, you need to create a new project and include the OpenFeat
You’ll then need to write the provider by implementing the `FeatureProvider` interface exported by the OpenFeature SDK.

```kotlin
class NewProvider(override val hooks: List<Hook<*>>, override val metadata: Metadata) : FeatureProvider {
class NewProvider(override val hooks: List<Hook<*>>, override val metadata: ProviderMetadata) : FeatureProvider {
override fun getBooleanEvaluation(
key: String,
defaultValue: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/client/swift.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This content has been automatically generated from swift-sdk.
Edits should be made here: https://github.com/open-feature/swift-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:16 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/client/web/angular.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
Edits should be made here: https://github.com/open-feature/js-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:16 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
-->

<p align="center" class="github-badges">
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/client/web/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
Edits should be made here: https://github.com/open-feature/js-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:16 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/client/web/react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
Edits should be made here: https://github.com/open-feature/js-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:16 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
114 changes: 44 additions & 70 deletions docs/reference/sdks/server/dart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This content has been automatically generated from dart-server-sdk.
Edits should be made here: https://github.com/open-feature/dart-server-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:16 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
-->

<p align="center" class="github-badges">
Expand All @@ -19,8 +19,8 @@ Last updated at Mon Apr 13 2026 08:52:16 GMT+0000 (Coordinated Universal Time)
</a>


<a href="https://github.com/open-feature/dart-server-sdk/releases/tag/v0.0.17">
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v0.0.17&color=blue&style=for-the-badge" />
<a href="https://github.com/open-feature/dart-server-sdk/releases/tag/v0.0.18">
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v0.0.18&color=blue&style=for-the-badge" />
</a>

<a href="https://dart.dev/">
Expand All @@ -47,7 +47,7 @@ Last updated at Mon Apr 13 2026 08:52:16 GMT+0000 (Coordinated Universal Time)

### Requirements

Dart language version: [3.9.2](https://dart.dev/get-dart/archive)
Dart language version: [3.10.7](https://dart.dev/get-dart/archive)

> [!NOTE]
> The OpenFeature DartServer SDK only supports the latest currently maintained Dart language versions.
Expand All @@ -56,7 +56,7 @@ Dart language version: [3.9.2](https://dart.dev/get-dart/archive)

```yaml
dependencies:
openfeature_dart_server_sdk: ^0.0.17
openfeature_dart_server_sdk: ^0.0.18
```

### Then run:
Expand All @@ -75,7 +75,7 @@ import 'package:openfeature_dart_server_sdk/feature_provider.dart';
void main() async {
// Get the API instance
final api = OpenFeatureAPI();

// Register your feature flag provider and wait for it to be ready
await api.setProviderAndWait(InMemoryProvider({
'new-feature': true,
Expand Down Expand Up @@ -159,13 +159,14 @@ api.setGlobalContext(OpenFeatureEvaluationContext({
'region': 'us-east-1-iah-1a',
}));

// Create a client with a specific evaluation context
// Create a client with a client-level default context
final client = FeatureClient(
metadata: ClientMetadata(name: 'my-app'),
hookManager: HookManager(),
defaultContext: EvaluationContext(attributes: {
'version': '1.4.6',
}),
provider: api.provider,
);

// Set a value to the invocation context
Expand Down Expand Up @@ -200,13 +201,13 @@ final client = FeatureClient(
metadata: ClientMetadata(name: 'my-app'),
hookManager: hookManager,
defaultContext: EvaluationContext(attributes: {}),
provider: api.provider,
);

// Create a hook for a specific evaluation
final myHook = MyHook();
// You can use the hook with a specific evaluation
```

> [!NOTE]
> Invocation-level hooks are not yet supported. Hooks can currently be registered at the global or client level.

### Tracking

The [tracking API](/specification/sections/tracking/) allows you to use OpenFeature abstractions and objects to associate user actions with feature flag evaluations.
Expand Down Expand Up @@ -239,49 +240,10 @@ await client.track(

Note that in accordance with the OpenFeature specification, the SDK doesn't generally log messages during flag evaluation.

#### Logging Hook

The Dart SDK includes a `LoggingHook`, which logs detailed information at key points during flag evaluation, using the [package:logging](https://pub.dev/packages/logging) structured logging API.
This hook can be particularly helpful for troubleshooting and debugging; simply attach it at the global, client or invocation level and ensure your log level is set to "debug".

##### Usage example

```dart
import 'package:logging/logging.dart';
import 'package:openfeature_dart_server_sdk/hooks.dart';

// Configure logging
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record) {
print('${record.time} [${record.level.name}] ${record.message}');
});

// Create a logging hook
final loggingHook = LoggingHook();

// Add the hook to your hook manager
final hookManager = HookManager();
hookManager.addHook(loggingHook);

// Create a client using this hook manager
final client = FeatureClient(
metadata: ClientMetadata(name: 'test-client'),
hookManager: hookManager,
defaultContext: EvaluationContext(attributes: {}),
);

// Evaluate a flag
final result = await client.getBooleanFlag('my-flag', defaultValue: false);
```

###### Output

```sh
{"time":"2024-10-23T13:33:09.8870867+03:00","level":"DEBUG","msg":"Before stage","domain":"test-client","provider_name":"InMemoryProvider","flag_key":"not-exist","default_value":true}
{"time":"2024-10-23T13:33:09.8968242+03:00","level":"ERROR","msg":"Error stage","domain":"test-client","provider_name":"InMemoryProvider","flag_key":"not-exist","default_value":true,"error_message":"error code: FLAG_NOT_FOUND: flag for key not-exist not found"}
```
The SDK uses the [package:logging](https://pub.dev/packages/logging) structured logging API internally.
You can configure log levels and listeners to capture SDK log output for troubleshooting and debugging.

See [hooks](#hooks) for more information on configuring hooks.
See [hooks](#hooks) for more information on adding custom logging behavior via hooks.

### Domains

Expand All @@ -302,10 +264,12 @@ api.setProvider(InMemoryProvider({'default-flag': true}));
api.bindClientToProvider('cache-domain', 'CachedProvider');

// Client backed by default provider
api.evaluateBooleanFlag('my-flag', 'default-client');
final defaultClient = api.getClient('default-client');
await defaultClient.getBooleanFlag('my-flag', defaultValue: false);

// Client backed by CachedProvider
api.evaluateBooleanFlag('my-flag', 'cache-domain');
final cacheClient = api.getClient('cache-client', domain: 'cache-domain');
await cacheClient.getBooleanFlag('my-flag', defaultValue: false);
```

### Eventing
Expand All @@ -323,19 +287,28 @@ import 'package:openfeature_dart_server_sdk/open_feature_event.dart';
// Get the OpenFeature API instance
final api = OpenFeatureAPI();

// Listen for provider change events
// Listen for provider configuration change events
api.events.listen((event) {
if (event.type == OpenFeatureEventType.providerChanged) {
print('Provider changed: ${event.message}');
if (event.type == OpenFeatureEventType.PROVIDER_CONFIGURATION_CHANGED) {
print('Provider configuration changed: ${event.message}');
}
});
```

The SDK also provides a global event bus for flag evaluation events:

```dart
import 'package:openfeature_dart_server_sdk/event_system.dart';

// Listen for flag evaluation events
api.events.listen((event) {
if (event.type == OpenFeatureEventType.flagEvaluated) {
OpenFeatureEvents.instance.subscribe(
(event) {
print('Flag evaluated: ${event.data['flagKey']} = ${event.data['result']}');
}
});
},
filter: EventFilter(
types: {OpenFeatureEventType.flagEvaluated},
),
);
```

### Shutdown
Expand Down Expand Up @@ -373,7 +346,7 @@ Transaction context can be set where specific data is available (e.g. an auth se
```dart
import 'package:openfeature_dart_server_sdk/transaction_context.dart';

// Create a transaction context manager
// Get the transaction context manager (singleton)
final transactionManager = TransactionContextManager();

// Set the transaction context
Expand Down Expand Up @@ -418,6 +391,9 @@ class MyCustomProvider implements FeatureProvider {
@override
String get name => 'MyCustomProvider';

@override
ProviderMetadata get metadata => ProviderMetadata(name: name);

@override
ProviderState get state => ProviderState.READY;

Expand Down Expand Up @@ -531,9 +507,9 @@ class MyCustomProvider implements FeatureProvider {

To develop a hook, you need to create a new project and include the OpenFeature SDK as a dependency.
This can be a new repository or included in [the existing contrib repository](https://github.com/open-feature/dart-server-sdk-contrib) available under the OpenFeature organization.
Implement your own hook by conforming to the [Hook interface](https://github.com/open-feature/dart-server-sdk/blob/main/pkg/openfeature/hooks.dart).
To satisfy the interface, all methods (`Before`/`After`/`Finally`/`Error`) need to be defined.
To avoid defining empty functions make use of the `UnimplementedHook` struct (which already implements all the empty functions).
Implement your own hook by conforming to the [Hook interface](https://github.com/open-feature/dart-server-sdk/blob/main/lib/hooks.dart).
To satisfy the interface, all methods (`before`/`after`/`finally_`/`error`) need to be defined.
To avoid defining empty functions, extend the `BaseHook` class (which provides no-op default implementations for all methods).

```dart
import 'dart:async';
Expand Down Expand Up @@ -577,10 +553,8 @@ class MyCustomHook extends BaseHook {

## Testing

The SDK provides a `NewTestProvider` which allows you to set flags for the scope of a test.
The `TestProvider` is thread-safe and can be used in tests that run in parallel.

Call `testProvider.UsingFlags(t, tt.flags)` to set flags for a test, and clean them up with `testProvider.Cleanup()`
Use the `InMemoryProvider` to set flags for the scope of a test.
Use `OpenFeatureAPI.resetInstance()` in `tearDown` to clean up between tests.

```dart
import 'package:test/test.dart';
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/server/dotnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This content has been automatically generated from dotnet-sdk.
Edits should be made here: https://github.com/open-feature/dotnet-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:15 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/server/go.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This content has been automatically generated from go-sdk.
Edits should be made here: https://github.com/open-feature/go-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:15 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/server/java.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This content has been automatically generated from java-sdk.
Edits should be made here: https://github.com/open-feature/java-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:15 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/server/javascript/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
Edits should be made here: https://github.com/open-feature/js-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:15 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/server/javascript/nestjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This content has been automatically generated from js-sdk.
Edits should be made here: https://github.com/open-feature/js-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:15 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/server/php.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This content has been automatically generated from php-sdk.
Edits should be made here: https://github.com/open-feature/php-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:15 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/server/python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This content has been automatically generated from python-sdk.
Edits should be made here: https://github.com/open-feature/python-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:15 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sdks/server/ruby.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This content has been automatically generated from ruby-sdk.
Edits should be made here: https://github.com/open-feature/ruby-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

Last updated at Mon Apr 13 2026 08:52:16 GMT+0000 (Coordinated Universal Time)
Last updated at Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
Loading
Loading