@statsig/react-bindings
Advanced tools
+2
-2
| { | ||
| "name": "@statsig/react-bindings", | ||
| "version": "0.0.1-beta.12", | ||
| "version": "0.0.1-beta.13", | ||
| "dependencies": { | ||
| "@statsig/client-core": "0.0.1-beta.12" | ||
| "@statsig/client-core": "0.0.1-beta.13" | ||
| }, | ||
@@ -7,0 +7,0 @@ "peerDependencies": { |
@@ -1,4 +0,5 @@ | ||
| import { DynamicConfig } from '@statsig/client-core'; | ||
| import { UseConfigOptions } from './useConfigImpl'; | ||
| export type UseDynamicConfigOptions = UseConfigOptions; | ||
| import { DynamicConfig, DynamicConfigEvaluationOptions, StatsigUser } from '@statsig/client-core'; | ||
| export type UseDynamicConfigOptions = DynamicConfigEvaluationOptions & { | ||
| user: StatsigUser | null; | ||
| }; | ||
| export default function (configName: string, options?: UseDynamicConfigOptions): DynamicConfig; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const react_1 = require("react"); | ||
| const client_core_1 = require("@statsig/client-core"); | ||
| const useConfigImpl_1 = require("./useConfigImpl"); | ||
| function default_1(configName, options = Object.assign(Object.assign({}, client_core_1.DEFAULT_EVAL_OPTIONS), { user: null })) { | ||
| return (0, useConfigImpl_1.useConfigImpl)('useDynamicConfig', configName, options); | ||
| const NoopEvaluationsClient_1 = require("./NoopEvaluationsClient"); | ||
| const OnDeviceVsPrecomputedUtils_1 = require("./OnDeviceVsPrecomputedUtils"); | ||
| const StatsigContext_1 = require("./StatsigContext"); | ||
| function default_1(configName, options) { | ||
| const { client, renderVersion } = (0, react_1.useContext)(StatsigContext_1.default); | ||
| return (0, react_1.useMemo)(() => { | ||
| if ((0, OnDeviceVsPrecomputedUtils_1.isPrecomputedEvalClient)(client)) { | ||
| return client.getExperiment(configName, options); | ||
| } | ||
| if ((options === null || options === void 0 ? void 0 : options.user) != null) { | ||
| return client.getExperiment(configName, options.user, options); | ||
| } | ||
| client_core_1.Log.warn(`useDynamicConfig hook failed to find a valid Statsig client for dynamic config '${configName}'.`); | ||
| return NoopEvaluationsClient_1.NoopEvaluationsClient.getExperiment(configName, options); | ||
| }, [configName, renderVersion, options]); | ||
| } | ||
| exports.default = default_1; |
@@ -1,4 +0,5 @@ | ||
| import { Experiment } from '@statsig/client-core'; | ||
| import { UseConfigOptions } from './useConfigImpl'; | ||
| export type UseExperimentOptions = UseConfigOptions; | ||
| import { Experiment, ExperimentEvaluationOptions, StatsigUser } from '@statsig/client-core'; | ||
| export type UseExperimentOptions = ExperimentEvaluationOptions & { | ||
| user: StatsigUser | null; | ||
| }; | ||
| export default function (experimentName: string, options?: UseExperimentOptions): Experiment; |
+16
-3
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const react_1 = require("react"); | ||
| const client_core_1 = require("@statsig/client-core"); | ||
| const useConfigImpl_1 = require("./useConfigImpl"); | ||
| function default_1(experimentName, options = Object.assign(Object.assign({}, client_core_1.DEFAULT_EVAL_OPTIONS), { user: null })) { | ||
| return (0, useConfigImpl_1.useConfigImpl)('useExperiment', experimentName, options); | ||
| const NoopEvaluationsClient_1 = require("./NoopEvaluationsClient"); | ||
| const OnDeviceVsPrecomputedUtils_1 = require("./OnDeviceVsPrecomputedUtils"); | ||
| const StatsigContext_1 = require("./StatsigContext"); | ||
| function default_1(experimentName, options) { | ||
| const { client, renderVersion } = (0, react_1.useContext)(StatsigContext_1.default); | ||
| return (0, react_1.useMemo)(() => { | ||
| if ((0, OnDeviceVsPrecomputedUtils_1.isPrecomputedEvalClient)(client)) { | ||
| return client.getExperiment(experimentName, options); | ||
| } | ||
| if ((options === null || options === void 0 ? void 0 : options.user) != null) { | ||
| return client.getExperiment(experimentName, options.user, options); | ||
| } | ||
| client_core_1.Log.warn(`useGate hook failed to find a valid Statsig client for experiment '${experimentName}'.`); | ||
| return NoopEvaluationsClient_1.NoopEvaluationsClient.getExperiment(experimentName, options); | ||
| }, [experimentName, renderVersion, options]); | ||
| } | ||
| exports.default = default_1; |
+2
-2
@@ -1,5 +0,5 @@ | ||
| import { EvaluationOptions, FeatureGate, StatsigUser } from '@statsig/client-core'; | ||
| export type UseGateOptions = EvaluationOptions & { | ||
| import { FeatureGate, FeatureGateEvaluationOptions, StatsigUser } from '@statsig/client-core'; | ||
| export type UseGateOptions = FeatureGateEvaluationOptions & { | ||
| user: StatsigUser | null; | ||
| }; | ||
| export default function (gateName: string, options?: UseGateOptions): FeatureGate; |
+2
-2
@@ -8,3 +8,3 @@ "use strict"; | ||
| const StatsigContext_1 = require("./StatsigContext"); | ||
| function default_1(gateName, options = Object.assign(Object.assign({}, client_core_1.DEFAULT_EVAL_OPTIONS), { user: null })) { | ||
| function default_1(gateName, options) { | ||
| const { client, renderVersion } = (0, react_1.useContext)(StatsigContext_1.default); | ||
@@ -15,3 +15,3 @@ const gate = (0, react_1.useMemo)(() => { | ||
| } | ||
| if (options.user != null) { | ||
| if ((options === null || options === void 0 ? void 0 : options.user) != null) { | ||
| return client.getFeatureGate(gateName, options.user, options); | ||
@@ -18,0 +18,0 @@ } |
@@ -1,5 +0,5 @@ | ||
| import { EvaluationOptions, Layer, StatsigUser } from '@statsig/client-core'; | ||
| export type UseLayerOptions = EvaluationOptions & { | ||
| import { Layer, LayerEvaluationOptions, StatsigUser } from '@statsig/client-core'; | ||
| export type UseLayerOptions = LayerEvaluationOptions & { | ||
| user: StatsigUser | null; | ||
| }; | ||
| export default function (layerName: string, options?: UseLayerOptions): Layer; |
+2
-2
@@ -8,3 +8,3 @@ "use strict"; | ||
| const StatsigContext_1 = require("./StatsigContext"); | ||
| function default_1(layerName, options = Object.assign(Object.assign({}, client_core_1.DEFAULT_EVAL_OPTIONS), { user: null })) { | ||
| function default_1(layerName, options) { | ||
| const { client, renderVersion } = (0, react_1.useContext)(StatsigContext_1.default); | ||
@@ -15,3 +15,3 @@ const layer = (0, react_1.useMemo)(() => { | ||
| } | ||
| if (options.user != null) { | ||
| if ((options === null || options === void 0 ? void 0 : options.user) != null) { | ||
| return client.getLayer(layerName, options.user, options); | ||
@@ -18,0 +18,0 @@ } |
| import { DynamicConfig, EvaluationOptions, StatsigUser } from '@statsig/client-core'; | ||
| export type UseConfigOptions = EvaluationOptions & { | ||
| user: StatsigUser | null; | ||
| }; | ||
| export declare function useConfigImpl(hook: 'useExperiment' | 'useDynamicConfig', configName: string, options?: UseConfigOptions): DynamicConfig; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.useConfigImpl = void 0; | ||
| const react_1 = require("react"); | ||
| const client_core_1 = require("@statsig/client-core"); | ||
| const NoopEvaluationsClient_1 = require("./NoopEvaluationsClient"); | ||
| const OnDeviceVsPrecomputedUtils_1 = require("./OnDeviceVsPrecomputedUtils"); | ||
| const StatsigContext_1 = require("./StatsigContext"); | ||
| function useConfigImpl(hook, configName, options = Object.assign(Object.assign({}, client_core_1.DEFAULT_EVAL_OPTIONS), { user: null })) { | ||
| const { client, renderVersion } = (0, react_1.useContext)(StatsigContext_1.default); | ||
| const config = (0, react_1.useMemo)(() => { | ||
| if ((0, OnDeviceVsPrecomputedUtils_1.isPrecomputedEvalClient)(client)) { | ||
| return client.getDynamicConfig(configName, options); | ||
| } | ||
| if (options.user != null) { | ||
| return client.getDynamicConfig(configName, options.user, options); | ||
| } | ||
| const type = hook === 'useDynamicConfig' ? 'dynamic config' : 'experiment'; | ||
| client_core_1.Log.warn(`${hook} hook failed to find a valid Statsig client for ${type} '${configName}'.`); | ||
| return NoopEvaluationsClient_1.NoopEvaluationsClient.getDynamicConfig(configName, options); | ||
| }, [configName, renderVersion, options]); | ||
| return config; | ||
| } | ||
| exports.useConfigImpl = useConfigImpl; |
17600
-0.88%26
-7.14%349
-0.29%+ Added
- Removed