|
1 |
| -//TODO: inline LD types so we can drop it from devDeps |
| 1 | +/** |
| 2 | + * Inline definitions of LaunchDarkly types so we don't have to include their |
| 3 | + * SDK in devDependencies. These are only for type-checking and can be extended |
| 4 | + * as needed - for exact definitions, reference `launchdarkly-js-client-sdk`. |
| 5 | + */ |
| 6 | + |
| 7 | +/** |
| 8 | + * Currently, the Sentry integration does not read from values of this type. |
| 9 | + */ |
| 10 | +export type LDContext = object; |
| 11 | + |
| 12 | +/** |
| 13 | + * An object that combines the result of a feature flag evaluation with information about |
| 14 | + * how it was calculated. |
| 15 | + */ |
| 16 | +export interface LDEvaluationDetail { |
| 17 | + value: unknown; |
| 18 | + // unused optional props: variationIndex and reason |
| 19 | +} |
| 20 | + |
| 21 | +/** |
| 22 | + * Callback interface for collecting information about the SDK at runtime. |
| 23 | + * |
| 24 | + * This interface is used to collect information about flag usage. |
| 25 | + * |
| 26 | + * This interface should not be used by the application to access flags for the purpose of controlling application |
| 27 | + * flow. It is intended for monitoring, analytics, or debugging purposes. |
| 28 | + */ |
| 29 | +export interface LDInspectionFlagUsedHandler { |
| 30 | + type: 'flag-used'; |
| 31 | + |
| 32 | + /** |
| 33 | + * Name of the inspector. Will be used for logging issues with the inspector. |
| 34 | + */ |
| 35 | + name: string; |
| 36 | + |
| 37 | + /** |
| 38 | + * If `true`, then the inspector will be ran synchronously with evaluation. |
| 39 | + * Synchronous inspectors execute inline with evaluation and care should be taken to ensure |
| 40 | + * they have minimal performance overhead. |
| 41 | + */ |
| 42 | + synchronous?: boolean; |
| 43 | + |
| 44 | + /** |
| 45 | + * This method is called when a flag is accessed via a variation method, or it can be called based on actions in |
| 46 | + * wrapper SDKs which have different methods of tracking when a flag was accessed. It is not called when a call is made |
| 47 | + * to allFlags. |
| 48 | + */ |
| 49 | + method: (flagKey: string, flagDetail: LDEvaluationDetail, context: LDContext) => void; |
| 50 | +} |
0 commit comments