Skip to content
Closed
Changes from 1 commit
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,51 @@
---
title: OpenFeature
description: "Attaches recent OpenFeature feature flag evaluations to error event context."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: "Attaches recent OpenFeature feature flag evaluations to error event context."
description: "Learn how to attach Sentry's OpenFeature feature flag evaluations to error event context."

notSupported:
- javascript.aws-lambda
- javascript.azure-functions
- javascript.bun
- javascript.capacitor
- javascript.cloudflare
- javascript.connect
- javascript.cordova
- javascript.deno
- javascript.electron
- javascript.express
- javascript.fastify
- javascript.gcp-functions
- javascript.hapi
- javascript.koa
- javascript.nestjs
- javascript.nodejs
- javascript.wasm
---

<Alert level="info">

This integration only works inside a browser environment.

</Alert>

_Import name: `Sentry.openFeatureIntegration` and `Sentry.OpenFeatureIntegrationHook`_
Copy link
Member

@michellewzhang michellewzhang Nov 27, 2024

Choose a reason for hiding this comment

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

maybe we should also add an alert saying this is in beta to match the other docs (same with the LD JS doc too)

i've been doing this:

<Alert level="info" title="Currently in Beta">

The support for **feature flag change tracking** and **feature flag evaluation tracking** is currently in beta.

</Alert>


The [OpenFeature](https://https://openfeature.dev/) integration tracks feature flag evaluations produced by the OpenFeature SDK. These evaluations are held in memory and, in the event an error occurs, sent to Sentry for review and analysis. **At the moment, we only support boolean flag evaluations.**
Copy link
Contributor

@lizokm lizokm Nov 18, 2024

Choose a reason for hiding this comment

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

Suggested change
The [OpenFeature](https://https://openfeature.dev/) integration tracks feature flag evaluations produced by the OpenFeature SDK. These evaluations are held in memory and, in the event an error occurs, sent to Sentry for review and analysis. **At the moment, we only support boolean flag evaluations.**
The [OpenFeature](https://openfeature.dev/) integration tracks feature flag evaluations produced by the OpenFeature SDK. These evaluations are held in memory and, if an error occurs, sent to Sentry for review and analysis. **At the moment, we only support boolean flag evaluations.**


```JavaScript
import * as Sentry from '@sentry/browser';
import { OpenFeature } from '@openfeature/web-sdk';

Sentry.init({integrations: [Sentry.openFeatureIntegration()]});

const client = OpenFeature.getClient();
client.addHooks(new OpenFeatureIntegrationHook());
Copy link
Member

Choose a reason for hiding this comment

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

More of a review to be done here: getsentry/sentry-javascript#14326

But could the integration itself do this? Since it's a "global" function that we're calling we could just auto register and avoid having the user do this bit of code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not without taking on a dependency. We either ask them to pass the client to us at integration init time (which may or may not be desired depending on their code's structure) or we ask them to register the hook explicitly. Just my two cents. Could be more options I don't know about.

Copy link
Member

Choose a reason for hiding this comment

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

should this be Sentry.OpenFeatureIntegrationHook?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes thank you!

Copy link
Member

Choose a reason for hiding this comment

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

Not without taking on a dependency.

I see so we're not shipping a @sentry/openfeature here and this is the way?

It's not the easist set up but it does make our lives much easier for now at least (no additional package requirements)

Copy link
Member Author

@cmanallen cmanallen Nov 15, 2024

Choose a reason for hiding this comment

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

Yeah its just a browser integration so no extra install steps. I agree its not an ideal setup. But I don't think its unexpected setup friction either.

If one day the flag buffer is a property on the scope we could remove the integration registration step all together and just have people register the hook. Which would be a one line change on the customer's side rather than two.

Copy link
Member Author

Choose a reason for hiding this comment

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


// Evaluating flags will record the result on the Sentry client.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Evaluating flags will record the result on the Sentry client.
// When you evaluate flags, the result will be recorded by the Sentry client.

const result = client.getBooleanValue('my-flag', false);
```

Learn more about the OpenFeature SDK at https://github.com/open-feature/js-sdk/tree/main.

## Options

There are no setup options for this integration.
Comment on lines +49 to +51
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## Options
There are no setup options for this integration.
## Options
There are no setup options for this integration.

Maybe it's better to just not have this section since there aren't any options?

Loading