@statsig/react-bindings 0.0.1-beta.6 → 0.0.1-beta.8
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/README.md
CHANGED
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.8",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@statsig/client-core": "0.0.1-beta.
|
|
5
|
+
"@statsig/client-core": "0.0.1-beta.8"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"react": "^16.6.3 || ^17.0.0 || ^18.0.0"
|
|
@@ -26,9 +26,11 @@ var defaultEvaluation = function (type) {
|
|
|
26
26
|
var client = {
|
|
27
27
|
isNoop: true,
|
|
28
28
|
loadingStatus: 'Uninitialized',
|
|
29
|
-
|
|
29
|
+
initializeSync: noop,
|
|
30
|
+
initializeAsync: function () { return Promise.resolve(); },
|
|
30
31
|
shutdown: function () { return Promise.resolve(); },
|
|
31
|
-
|
|
32
|
+
updateUserSync: noop,
|
|
33
|
+
updateUserAsync: function (_u) { return Promise.resolve(); },
|
|
32
34
|
getCurrentUser: function () { return ({ userID: '' }); },
|
|
33
35
|
checkGate: function () { return false; },
|
|
34
36
|
getFeatureGate: defaultEvaluation('gate'),
|
|
@@ -6,7 +6,7 @@ function isPrecomputedEvaluationsClient(client) {
|
|
|
6
6
|
if ('isNoop' in client) {
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
|
-
return '
|
|
9
|
+
return 'updateUserSync' in client;
|
|
10
10
|
}
|
|
11
11
|
exports.isPrecomputedEvaluationsClient = isPrecomputedEvaluationsClient;
|
|
12
12
|
function logMissingStatsigUserWarning() {
|
package/src/StatsigProvider.js
CHANGED
|
@@ -14,7 +14,7 @@ function StatsigProvider(props) {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
client.on('status_change', onStatusChange);
|
|
17
|
-
client.
|
|
17
|
+
client.initializeSync();
|
|
18
18
|
return function () {
|
|
19
19
|
client.shutdown().catch(function (error) {
|
|
20
20
|
client_core_1.Log.error('An error occured during shutdown', error);
|
package/src/useStatsigUser.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StatsigUser } from '@statsig/client-core';
|
|
2
2
|
export type UseStatsigUserResult = {
|
|
3
3
|
user: StatsigUser;
|
|
4
|
-
|
|
4
|
+
updateUserSync: (fn: (prevState: StatsigUser) => StatsigUser) => void;
|
|
5
|
+
updateUserAsync: (fn: (prevState: StatsigUser) => StatsigUser) => Promise<void>;
|
|
5
6
|
};
|
|
6
7
|
export default function (): UseStatsigUserResult;
|
package/src/useStatsigUser.js
CHANGED
|
@@ -5,9 +5,13 @@ function default_1() {
|
|
|
5
5
|
var client = (0, useStatsigPrecomputedEvaluationsClient_1.default)();
|
|
6
6
|
return {
|
|
7
7
|
user: client.getCurrentUser(),
|
|
8
|
-
|
|
8
|
+
updateUserSync: function (fn) {
|
|
9
9
|
var user = fn(client.getCurrentUser());
|
|
10
|
-
client.
|
|
10
|
+
client.updateUserSync(user);
|
|
11
|
+
},
|
|
12
|
+
updateUserAsync: function (fn) {
|
|
13
|
+
var user = fn(client.getCurrentUser());
|
|
14
|
+
return client.updateUserAsync(user);
|
|
11
15
|
},
|
|
12
16
|
};
|
|
13
17
|
}
|