Skip to content

Commit 90714e1

Browse files
committed
Init[WIP]
1 parent 3693a5d commit 90714e1

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

packages/browser/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ export {
7575
} from './integrations/featureFlags';
7676
export { launchDarklyIntegration, buildLaunchDarklyFlagUsedHandler } from './integrations/featureFlags/launchdarkly';
7777
export { openFeatureIntegration, OpenFeatureIntegrationHook } from './integrations/featureFlags/openfeature';
78+
export { unleashIntegration } from './integrations/featureFlags/unleash';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { unleashIntegration } from './integration';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { Client, Event, EventHint, IntegrationFn } from '@sentry/core';
2+
3+
import { defineIntegration } from '@sentry/core';
4+
import { copyFlagsFromScopeToEvent, insertFlagToScope } from '../../../utils/featureFlags';
5+
import type { UnleashClient } from './types';
6+
7+
/**
8+
* Sentry integration for capturing feature flags from the Unleash 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+
* TODO:
16+
*
17+
* Sentry.init({
18+
* dsn: '___PUBLIC_DSN___',
19+
* integrations: [TODO:]
20+
* });
21+
* ```
22+
*/
23+
export const unleashIntegration = defineIntegration((openFeatureClient: UnleashClient ) => {
24+
return {
25+
name: 'Unleash',
26+
27+
processEvent(event: Event, _hint: EventHint, _client: Client): Event {
28+
return copyFlagsFromScopeToEvent(event);
29+
},
30+
31+
setupOnce() {
32+
openFeatureClient.isEnabled = Proxy();
33+
openFeatureClient.getVariant = Proxy();
34+
},
35+
};
36+
}) satisfies IntegrationFn;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export type Variant = {
2+
variantName: string;
3+
enabled: boolean;
4+
payload?: object; // TODO:
5+
// TODO:
6+
}
7+
8+
export interface UnleashClient {
9+
isEnabled(featureName: string): boolean;
10+
getVariant(featureName: string): Variant;
11+
}

0 commit comments

Comments
 (0)