@statsig/react-bindings 0.0.1-beta.12 → 0.0.1-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/useDynamicConfig.d.ts +4 -3
- package/src/useDynamicConfig.js +16 -3
- package/src/useExperiment.d.ts +4 -3
- package/src/useExperiment.js +16 -3
- package/src/useGate.d.ts +2 -2
- package/src/useGate.js +2 -2
- package/src/useLayer.d.ts +2 -2
- package/src/useLayer.js +2 -2
- package/src/useConfigImpl.d.ts +0 -5
- package/src/useConfigImpl.js +0 -24
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/react-bindings",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.13",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@statsig/client-core": "0.0.1-beta.
|
|
5
|
+
"@statsig/client-core": "0.0.1-beta.13"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"react": "^16.6.3 || ^17.0.0 || ^18.0.0"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DynamicConfig } from '@statsig/client-core';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { DynamicConfig, DynamicConfigEvaluationOptions, StatsigUser } from '@statsig/client-core';
|
|
2
|
+
export type UseDynamicConfigOptions = DynamicConfigEvaluationOptions & {
|
|
3
|
+
user: StatsigUser | null;
|
|
4
|
+
};
|
|
4
5
|
export default function (configName: string, options?: UseDynamicConfigOptions): DynamicConfig;
|
package/src/useDynamicConfig.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
3
4
|
const client_core_1 = require("@statsig/client-core");
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const NoopEvaluationsClient_1 = require("./NoopEvaluationsClient");
|
|
6
|
+
const OnDeviceVsPrecomputedUtils_1 = require("./OnDeviceVsPrecomputedUtils");
|
|
7
|
+
const StatsigContext_1 = require("./StatsigContext");
|
|
8
|
+
function default_1(configName, options) {
|
|
9
|
+
const { client, renderVersion } = (0, react_1.useContext)(StatsigContext_1.default);
|
|
10
|
+
return (0, react_1.useMemo)(() => {
|
|
11
|
+
if ((0, OnDeviceVsPrecomputedUtils_1.isPrecomputedEvalClient)(client)) {
|
|
12
|
+
return client.getExperiment(configName, options);
|
|
13
|
+
}
|
|
14
|
+
if ((options === null || options === void 0 ? void 0 : options.user) != null) {
|
|
15
|
+
return client.getExperiment(configName, options.user, options);
|
|
16
|
+
}
|
|
17
|
+
client_core_1.Log.warn(`useDynamicConfig hook failed to find a valid Statsig client for dynamic config '${configName}'.`);
|
|
18
|
+
return NoopEvaluationsClient_1.NoopEvaluationsClient.getExperiment(configName, options);
|
|
19
|
+
}, [configName, renderVersion, options]);
|
|
7
20
|
}
|
|
8
21
|
exports.default = default_1;
|
package/src/useExperiment.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Experiment } from '@statsig/client-core';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Experiment, ExperimentEvaluationOptions, StatsigUser } from '@statsig/client-core';
|
|
2
|
+
export type UseExperimentOptions = ExperimentEvaluationOptions & {
|
|
3
|
+
user: StatsigUser | null;
|
|
4
|
+
};
|
|
4
5
|
export default function (experimentName: string, options?: UseExperimentOptions): Experiment;
|
package/src/useExperiment.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
3
4
|
const client_core_1 = require("@statsig/client-core");
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const NoopEvaluationsClient_1 = require("./NoopEvaluationsClient");
|
|
6
|
+
const OnDeviceVsPrecomputedUtils_1 = require("./OnDeviceVsPrecomputedUtils");
|
|
7
|
+
const StatsigContext_1 = require("./StatsigContext");
|
|
8
|
+
function default_1(experimentName, options) {
|
|
9
|
+
const { client, renderVersion } = (0, react_1.useContext)(StatsigContext_1.default);
|
|
10
|
+
return (0, react_1.useMemo)(() => {
|
|
11
|
+
if ((0, OnDeviceVsPrecomputedUtils_1.isPrecomputedEvalClient)(client)) {
|
|
12
|
+
return client.getExperiment(experimentName, options);
|
|
13
|
+
}
|
|
14
|
+
if ((options === null || options === void 0 ? void 0 : options.user) != null) {
|
|
15
|
+
return client.getExperiment(experimentName, options.user, options);
|
|
16
|
+
}
|
|
17
|
+
client_core_1.Log.warn(`useGate hook failed to find a valid Statsig client for experiment '${experimentName}'.`);
|
|
18
|
+
return NoopEvaluationsClient_1.NoopEvaluationsClient.getExperiment(experimentName, options);
|
|
19
|
+
}, [experimentName, renderVersion, options]);
|
|
7
20
|
}
|
|
8
21
|
exports.default = default_1;
|
package/src/useGate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type UseGateOptions =
|
|
1
|
+
import { FeatureGate, FeatureGateEvaluationOptions, StatsigUser } from '@statsig/client-core';
|
|
2
|
+
export type UseGateOptions = FeatureGateEvaluationOptions & {
|
|
3
3
|
user: StatsigUser | null;
|
|
4
4
|
};
|
|
5
5
|
export default function (gateName: string, options?: UseGateOptions): FeatureGate;
|
package/src/useGate.js
CHANGED
|
@@ -5,13 +5,13 @@ const client_core_1 = require("@statsig/client-core");
|
|
|
5
5
|
const NoopEvaluationsClient_1 = require("./NoopEvaluationsClient");
|
|
6
6
|
const OnDeviceVsPrecomputedUtils_1 = require("./OnDeviceVsPrecomputedUtils");
|
|
7
7
|
const StatsigContext_1 = require("./StatsigContext");
|
|
8
|
-
function default_1(gateName, options
|
|
8
|
+
function default_1(gateName, options) {
|
|
9
9
|
const { client, renderVersion } = (0, react_1.useContext)(StatsigContext_1.default);
|
|
10
10
|
const gate = (0, react_1.useMemo)(() => {
|
|
11
11
|
if ((0, OnDeviceVsPrecomputedUtils_1.isPrecomputedEvalClient)(client)) {
|
|
12
12
|
return client.getFeatureGate(gateName, options);
|
|
13
13
|
}
|
|
14
|
-
if (options.user != null) {
|
|
14
|
+
if ((options === null || options === void 0 ? void 0 : options.user) != null) {
|
|
15
15
|
return client.getFeatureGate(gateName, options.user, options);
|
|
16
16
|
}
|
|
17
17
|
client_core_1.Log.warn(`useGate hook failed to find a valid Statsig client for gate '${gateName}'.`);
|
package/src/useLayer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type UseLayerOptions =
|
|
1
|
+
import { Layer, LayerEvaluationOptions, StatsigUser } from '@statsig/client-core';
|
|
2
|
+
export type UseLayerOptions = LayerEvaluationOptions & {
|
|
3
3
|
user: StatsigUser | null;
|
|
4
4
|
};
|
|
5
5
|
export default function (layerName: string, options?: UseLayerOptions): Layer;
|
package/src/useLayer.js
CHANGED
|
@@ -5,13 +5,13 @@ const client_core_1 = require("@statsig/client-core");
|
|
|
5
5
|
const NoopEvaluationsClient_1 = require("./NoopEvaluationsClient");
|
|
6
6
|
const OnDeviceVsPrecomputedUtils_1 = require("./OnDeviceVsPrecomputedUtils");
|
|
7
7
|
const StatsigContext_1 = require("./StatsigContext");
|
|
8
|
-
function default_1(layerName, options
|
|
8
|
+
function default_1(layerName, options) {
|
|
9
9
|
const { client, renderVersion } = (0, react_1.useContext)(StatsigContext_1.default);
|
|
10
10
|
const layer = (0, react_1.useMemo)(() => {
|
|
11
11
|
if ((0, OnDeviceVsPrecomputedUtils_1.isPrecomputedEvalClient)(client)) {
|
|
12
12
|
return client.getLayer(layerName, options);
|
|
13
13
|
}
|
|
14
|
-
if (options.user != null) {
|
|
14
|
+
if ((options === null || options === void 0 ? void 0 : options.user) != null) {
|
|
15
15
|
return client.getLayer(layerName, options.user, options);
|
|
16
16
|
}
|
|
17
17
|
client_core_1.Log.warn(`useLayer hook failed to find a valid Statsig client for layer '${layerName}'.`);
|
package/src/useConfigImpl.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { DynamicConfig, EvaluationOptions, StatsigUser } from '@statsig/client-core';
|
|
2
|
-
export type UseConfigOptions = EvaluationOptions & {
|
|
3
|
-
user: StatsigUser | null;
|
|
4
|
-
};
|
|
5
|
-
export declare function useConfigImpl(hook: 'useExperiment' | 'useDynamicConfig', configName: string, options?: UseConfigOptions): DynamicConfig;
|
package/src/useConfigImpl.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useConfigImpl = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const client_core_1 = require("@statsig/client-core");
|
|
6
|
-
const NoopEvaluationsClient_1 = require("./NoopEvaluationsClient");
|
|
7
|
-
const OnDeviceVsPrecomputedUtils_1 = require("./OnDeviceVsPrecomputedUtils");
|
|
8
|
-
const StatsigContext_1 = require("./StatsigContext");
|
|
9
|
-
function useConfigImpl(hook, configName, options = Object.assign(Object.assign({}, client_core_1.DEFAULT_EVAL_OPTIONS), { user: null })) {
|
|
10
|
-
const { client, renderVersion } = (0, react_1.useContext)(StatsigContext_1.default);
|
|
11
|
-
const config = (0, react_1.useMemo)(() => {
|
|
12
|
-
if ((0, OnDeviceVsPrecomputedUtils_1.isPrecomputedEvalClient)(client)) {
|
|
13
|
-
return client.getDynamicConfig(configName, options);
|
|
14
|
-
}
|
|
15
|
-
if (options.user != null) {
|
|
16
|
-
return client.getDynamicConfig(configName, options.user, options);
|
|
17
|
-
}
|
|
18
|
-
const type = hook === 'useDynamicConfig' ? 'dynamic config' : 'experiment';
|
|
19
|
-
client_core_1.Log.warn(`${hook} hook failed to find a valid Statsig client for ${type} '${configName}'.`);
|
|
20
|
-
return NoopEvaluationsClient_1.NoopEvaluationsClient.getDynamicConfig(configName, options);
|
|
21
|
-
}, [configName, renderVersion, options]);
|
|
22
|
-
return config;
|
|
23
|
-
}
|
|
24
|
-
exports.useConfigImpl = useConfigImpl;
|