File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -50,3 +50,11 @@ test('filters to target flags', () => {
5050
5151 expect ( flags ) . toEqual ( { fooBar : 'foobar' } ) ;
5252} ) ;
53+
54+ test ( 'does not use proxy if option is false' , ( ) => {
55+ const { flags } = getFlagsProxy ( ldClient , rawFlags , { sendEventsOnFlagRead : false } ) ;
56+
57+ expect ( flags [ 'foo-bar' ] ) . toBe ( 'foobar' ) ;
58+
59+ expect ( variation ) . not . toHaveBeenCalled ( ) ;
60+ } ) ;
Original file line number Diff line number Diff line change @@ -21,12 +21,19 @@ export interface LDReactOptions {
2121 * @see https://docs.launchdarkly.com/sdk/client-side/react/react-web#flag-keys
2222 */
2323 useCamelCaseFlagKeys ?: boolean ;
24+
25+ /**
26+ * Whether to send flag evaluation events when a flag is read from the `flags` object
27+ * retured by the `useFlags` hook. This is true by default, meaning flag evaluation
28+ * events will be sent by default.
29+ */
30+ sendEventsOnFlagRead ?: boolean ;
2431}
2532
2633/**
2734 * Contains default values for the `reactOptions` object.
2835 */
29- export const defaultReactOptions = { useCamelCaseFlagKeys : true } ;
36+ export const defaultReactOptions = { useCamelCaseFlagKeys : true , sendEventsOnFlagRead : true } ;
3037
3138/**
3239 * Configuration object used to initialise LaunchDarkly's JS client.
You can’t perform that action at this time.
0 commit comments