1- /**
2- * OpenFeature integration.
3- *
4- * Add the openFeatureIntegration() function call to your integration lists.
5- * Add the integration hook to your OpenFeature object.
6- * - OpenFeature.getClient().addHooks(new OpenFeatureIntegrationHook());
7- */
81import type { Client , Event , EventHint , IntegrationFn } from '@sentry/core' ;
92import type { EvaluationDetails , HookContext , HookHints , JsonValue , OpenFeatureClient , OpenFeatureHook } from './types' ;
103
114import { defineIntegration } from '@sentry/core' ;
125import { copyFlagsFromScopeToEvent , insertFlagToScope } from '../../../utils/featureFlags' ;
136
7+ /**
8+ * Sentry integration for capturing feature flags from the OpenFeature SDK.
9+ *
10+ * See the [feature flag documentation](https://develop.sentry.dev/sdk/expected-features/#feature-flags) for more information.
11+ *
12+ * @example
13+ * ```
14+ * import * as Sentry from '@sentry/browser';
15+ * import { OpenFeature } from '@openfeature/web-sdk';
16+ *
17+ * OpenFeature.setProvider(new MyProviderOfChoice());
18+ * const client = OpenFeature.getClient();
19+ * const openFeatureIntegration = Sentry.openFeatureIntegration({openFeatureClient: client});
20+ *
21+ * Sentry.init({
22+ * dsn: '___PUBLIC_DSN___',
23+ * integrations: [openFeatureIntegration]
24+ * });
25+ * ```
26+ */
1427export const openFeatureIntegration = defineIntegration ( ( openFeatureClient : OpenFeatureClient ) => {
1528 return {
1629 name : 'OpenFeature' ,
@@ -26,7 +39,8 @@ export const openFeatureIntegration = defineIntegration((openFeatureClient: Open
2639} ) satisfies IntegrationFn ;
2740
2841/**
29- * OpenFeature Hook class implementation.
42+ * OpenFeatureHook class implementation. Listens for flag evaluations and
43+ * updates the `flags` context in our Sentry scope.
3044 */
3145class OpenFeatureIntegrationHook implements OpenFeatureHook {
3246 /**
0 commit comments