diff --git a/docs/platforms/python/integrations/openfeature/index.mdx b/docs/platforms/python/integrations/openfeature/index.mdx index 59b260e38699e..af2ebdc4ca8c1 100644 --- a/docs/platforms/python/integrations/openfeature/index.mdx +++ b/docs/platforms/python/integrations/openfeature/index.mdx @@ -19,7 +19,34 @@ pip install --upgrade 'sentry-sdk' Add `OpenFeatureIntegration()` to your `integrations` list: -```python +```python {tabTitle: sentry-sdk >= v2.TODO: (Track One Client)} +import sentry_sdk +from sentry_sdk.integrations.openfeature import OpenFeatureIntegration +from openfeature import api + +client = api.get_client() + +sentry_sdk.init( + dsn="___PUBLIC_DSN___", + integrations=[ + OpenFeatureIntegration(client=client), + ], +) +``` + +```python {tabTitle: sentry-sdk >= v2.TODO: (Track All Clients)} +import sentry_sdk +from sentry_sdk.integrations.openfeature import OpenFeatureIntegration + +sentry_sdk.init( + dsn="___PUBLIC_DSN___", + integrations=[ + OpenFeatureIntegration(), + ], +) +``` + +```python {tabTitle: sentry-sdk <= v2.TODO: (Track All Clients)} import sentry_sdk from sentry_sdk.integrations.openfeature import OpenFeatureIntegration @@ -35,7 +62,27 @@ sentry_sdk.init( The integration is tested by evaluating a feature flag using your OpenFeature SDK before capturing an exception. -```python +```python {tabTitle: sentry-sdk >= v2.TODO: (Track One Client)} +from openfeature import api +import sentry_sdk + +# Reference `client` from the Configure step. +client.get_boolean_value("hello", default_value=False) + +sentry_sdk.capture_exception(Exception("Something went wrong!")) +``` + +```python {tabTitle: sentry-sdk >= v2.TODO: (Track All Clients)} +from openfeature import api +import sentry_sdk + +client = api.get_client() +client.get_boolean_value("hello", default_value=False) + +sentry_sdk.capture_exception(Exception("Something went wrong!")) +``` + +```python {tabTitle: sentry-sdk <= v2.TODO: (Track All Clients)} from openfeature import api import sentry_sdk diff --git a/platform-includes/configuration/openfeature/javascript.mdx b/platform-includes/configuration/openfeature/javascript.mdx index 1af6993885a4f..9e9dafe60cbff 100644 --- a/platform-includes/configuration/openfeature/javascript.mdx +++ b/platform-includes/configuration/openfeature/javascript.mdx @@ -1,6 +1,23 @@ Before using this integration, you need to install and instrument the [OpenFeature SDK](https://www.npmjs.com/package/@openfeature/web-sdk) in your app. Learn more by reading OpenFeature's [SDK docs](https://openfeature.dev/docs/reference/technologies/client/web/) and [provider docs](https://openfeature.dev/docs/reference/concepts/provider). -```javascript {tabTitle: JavaScript (Track All Evals)} +```javascript {tabTitle: @sentry/browser >= v8.TODO: (Track One Client)} +import * as Sentry from '@sentry/browser'; +import { OpenFeature } from '@openfeature/web-sdk'; + +OpenFeature.setProvider(new MyProviderOfChoice()); +const client = OpenFeature.getClient(); +const openFeatureIntegration = Sentry.openFeatureIntegration({openFeatureClient: client}); + +Sentry.init({ + dsn: '___PUBLIC_DSN___', + integrations: [openFeatureIntegration] +}); + +const result = client.getBooleanValue('test-flag', false); // evaluate with a default value +Sentry.captureException(new Error('Something went wrong!')); +``` + +```javascript {tabTitle: @sentry/browser <= v8.TODO: (Track One Client)} import * as Sentry from '@sentry/browser'; import { OpenFeature } from '@openfeature/web-sdk'; @@ -10,14 +27,14 @@ Sentry.init({ }); OpenFeature.setProvider(new MyProviderOfChoice()); -OpenFeature.addHooks(new Sentry.OpenFeatureIntegrationHook()); - const client = OpenFeature.getClient(); +client.addHooks(new Sentry.OpenFeatureIntegrationHook()); + const result = client.getBooleanValue('test-flag', false); // evaluate with a default value Sentry.captureException(new Error('Something went wrong!')); ``` -```javascript {tabTitle: JavaScript (Track One Client)} +```javascript {tabTitle: @sentry/browser <= v8.TODO: (Track All Clients)} import * as Sentry from '@sentry/browser'; import { OpenFeature } from '@openfeature/web-sdk'; @@ -27,9 +44,9 @@ Sentry.init({ }); OpenFeature.setProvider(new MyProviderOfChoice()); -const client = OpenFeature.getClient(); -client.addHooks(new Sentry.OpenFeatureIntegrationHook()); +OpenFeature.addHooks(new Sentry.OpenFeatureIntegrationHook()); +const client = OpenFeature.getClient(); const result = client.getBooleanValue('test-flag', false); // evaluate with a default value Sentry.captureException(new Error('Something went wrong!')); ```