Skip to content
Merged
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
2 changes: 1 addition & 1 deletion 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 Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:16 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/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 Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:17 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 Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:17 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 Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:16 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 Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:16 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/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 Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:17 GMT+0000 (Coordinated Universal Time)
-->

<p align="center" class="github-badges">
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 Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:16 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
21 changes: 12 additions & 9 deletions 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 Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:16 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand All @@ -25,7 +25,7 @@ import MCPInstall from '@site/src/partials/mcp-install';

<br/>
<a href="https://pkg.go.dev/github.com/open-feature/go-sdk/openfeature">
<img alt="API Reference" src="https://pkg.go.dev/badge/github.com/open-feature/go-sdk/pkg/openfeature.svg" />
<img alt="API Reference" src="https://pkg.go.dev/badge/github.com/open-feature/go-sdk/openfeature.svg" />
</a>
<a href="https://goreportcard.com/report/github.com/open-feature/go-sdk">
<img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/open-feature/go-sdk" />
Expand Down Expand Up @@ -172,7 +172,7 @@ client.AddHooks(ExampleClientHook{})

// add a hook for this evaluation only
value, err := client.BooleanValue(
context.TODO(), "boolFlag", false, openfeature.EvaluationContext{}, WithHooks(ExampleInvocationHook{}),
context.TODO(), "boolFlag", false, openfeature.EvaluationContext{}, openfeature.WithHooks(ExampleInvocationHook{}),
)
```

Expand All @@ -184,12 +184,12 @@ For example, a flag enhancing the appearance of a UI component might drive user

```go
// initialize a client
client := openfeature.NewClient('my-app')
client := openfeature.NewClient("my-app")

// trigger tracking event action
client.Track(
context.TODO(),
'visited-promo-page',
"visited-promo-page",
openfeature.EvaluationContext{},
openfeature.NewTrackingEventDetails(99.77).Add("currencyCode", "USD"),
)
Expand Down Expand Up @@ -255,12 +255,15 @@ See [hooks](#hooks) for more information on configuring hooks.
Clients can be assigned to a domain. A domain is a logical identifier that can be used to associate clients with a particular provider. If a domain has no associated provider, the default provider is used.

```go
import "github.com/open-feature/go-sdk/openfeature"
import (
"github.com/open-feature/go-sdk/openfeature"
"github.com/open-feature/go-sdk/openfeature/memprovider"
)

// Registering the default provider
openfeature.SetProviderAndWait(NewLocalProvider())
openfeature.SetProviderAndWait(openfeature.NoopProvider{})
// Registering a named provider
openfeature.SetNamedProvider("clientForCache", NewCachedProvider())
openfeature.SetNamedProvider("clientForCache", memprovider.NewInMemoryProvider(map[string]memprovider.InMemoryFlag{}))

// A Client backed by default provider
clientWithDefault := openfeature.NewDefaultClient()
Expand Down Expand Up @@ -423,7 +426,7 @@ func (i MyFeatureProvider) EventChannel() <-chan openfeature.Event {

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/go-sdk-contrib) available under the OpenFeature organization.
Implement your own hook by conforming to the [Hook interface](https://github.com/open-feature/go-sdk/blob/main/pkg/openfeature/hooks.go).
Implement your own hook by conforming to the [Hook interface](https://github.com/open-feature/go-sdk/blob/main/openfeature/hooks.go).
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).

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 Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:15 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 Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:16 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 Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:16 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 Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:16 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down
18 changes: 10 additions & 8 deletions 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 Fri Apr 17 2026 08:43:11 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:16 GMT+0000 (Coordinated Universal Time)
-->
import MCPInstall from '@site/src/partials/mcp-install';

Expand Down Expand Up @@ -139,11 +139,11 @@ If the flag management system you're using supports targeting, you can provide t
```python
from openfeature.api import (
get_client,
get_provider,
set_provider,
get_evaluation_context,
set_evaluation_context,
)
from openfeature.evaluation_context import EvaluationContext

global_context = EvaluationContext(
targeting_key="targeting_key1", attributes={"application": "value1"}
Expand All @@ -156,7 +156,7 @@ request_context = EvaluationContext(
set_evaluation_context(global_context)

# merge second context
client = get_client(name="No-op Provider")
client = get_client(domain="No-op Provider")
client.get_string_value("email", "fallback", request_context)
```

Expand All @@ -169,19 +169,20 @@ If the hook you're looking for hasn't been created yet, see the [develop a hook]
Once you've added a hook as a dependency, it can be registered at the global, client, or flag invocation level.

```python
from openfeature import api
from openfeature.api import add_hooks
from openfeature.flag_evaluation import FlagEvaluationOptions

# set global hooks at the API-level
add_hooks([MyHook()])

# or configure them in the client
client = OpenFeatureClient()
client = api.get_client()
client.add_hooks([MyHook()])

# or at the invocation-level
options = FlagEvaluationOptions(hooks=[MyHook()])
client.get_boolean_flag("my-flag", False, flag_evaluation_options=options)
client.get_boolean_value("my-flag", False, flag_evaluation_options=options)
```
### Tracking

Expand Down Expand Up @@ -251,7 +252,7 @@ Please refer to the documentation of the provider you're using to see what event

```python
from openfeature import api
from openfeature.provider import ProviderEvent
from openfeature.event import EventDetails, ProviderEvent

def on_provider_ready(event_details: EventDetails):
print(f"Provider {event_details.provider_name} is ready")
Expand Down Expand Up @@ -500,10 +501,11 @@ Implement your own hook by creating a hook that inherits from the `Hook` class.
Any of the evaluation life-cycle stages (`before`/`after`/`error`/`finally_after`) can be override to add the desired business logic.

```python
from openfeature.hook import Hook
from openfeature.hook import Hook, HookContext, HookHints
from openfeature.flag_evaluation import FlagEvaluationDetails, FlagValueType

class MyHook(Hook):
def after(self, hook_context: HookContext, details: FlagEvaluationDetails, hints: dict):
def after(self, hook_context: HookContext, details: FlagEvaluationDetails[FlagValueType], hints: HookHints):
Comment on lines +505 to +508
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The type hint FlagEvaluationDetails[FlagValueType] is incorrect. FlagEvaluationDetails is a generic class where the type parameter represents the type of the flag value (e.g., bool, str, float, etc.), not the FlagValueType enum itself. Since this is a generic hook example, it's better to use FlagEvaluationDetails without a type argument (which defaults to Any) and remove the unused FlagValueType import.

from openfeature.flag_evaluation import FlagEvaluationDetails

class MyHook(Hook):
    def after(self, hook_context: HookContext, details: FlagEvaluationDetails, hints: HookHints):

print("This runs after the flag has been evaluated")

```
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 Fri Apr 17 2026 08:43:12 GMT+0000 (Coordinated Universal Time)
Last updated at Mon Apr 20 2026 08:55:17 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/rust.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This content has been automatically generated from rust-sdk.
Edits should be made here: https://github.com/open-feature/rust-sdk
Once a repo has been updated, docs can be generated by running: yarn update:sdk-docs

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

<p align="center" class="github-badges">
Expand Down
Loading