@statsig/react-bindings 3.9.0 → 3.10.0

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 CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@statsig/react-bindings",
3
- "version": "3.9.0",
3
+ "version": "3.10.0",
4
4
  "dependencies": {
5
- "@statsig/client-core": "3.9.0",
6
- "@statsig/js-client": "3.9.0"
5
+ "@statsig/client-core": "3.10.0",
6
+ "@statsig/js-client": "3.10.0"
7
7
  },
8
8
  "peerDependencies": {
9
9
  "react": "^16.6.3 || ^17.0.0 || ^18.0.0 || ^19.0.0"
@@ -2,10 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isNoopClient = exports.NoopEvaluationsClient = void 0;
4
4
  const client_core_1 = require("@statsig/client-core");
5
+ const noopInitializeDetails = {
6
+ success: false,
7
+ error: Error('NoClient'),
8
+ duration: 0,
9
+ source: 'Uninitialized',
10
+ sourceUrl: null,
11
+ };
5
12
  const _noop = () => {
6
13
  // noop
7
14
  };
15
+ const _noopWithInitializeDetails = () => noopInitializeDetails;
8
16
  const _noopAsync = () => Promise.resolve();
17
+ const _noopAsyncWithInitializeDetails = () => Promise.resolve(noopInitializeDetails);
9
18
  const NOOP_DETAILS = { reason: 'Error:NoClient' };
10
19
  const _defaultEvaluation = (type) => {
11
20
  return (...args) => {
@@ -46,13 +55,13 @@ const context = {
46
55
  const _client = {
47
56
  isNoop: true,
48
57
  loadingStatus: 'Uninitialized',
49
- initializeSync: _noop,
50
- initializeAsync: _noopAsync,
58
+ initializeSync: _noopWithInitializeDetails,
59
+ initializeAsync: _noopAsyncWithInitializeDetails,
51
60
  shutdown: _noopAsync,
52
61
  flush: _noopAsync,
53
62
  updateRuntimeOptions: _noop,
54
- updateUserSync: _noop,
55
- updateUserAsync: _noopAsync,
63
+ updateUserSync: _noopWithInitializeDetails,
64
+ updateUserAsync: _noopAsyncWithInitializeDetails,
56
65
  getContext: () => (Object.assign({}, context)),
57
66
  checkGate: () => false,
58
67
  getFeatureGate: _defaultEvaluation('gate'),
@@ -1,8 +1,8 @@
1
- import { StatsigUser } from '@statsig/client-core';
1
+ import { StatsigUpdateDetails, StatsigUser } from '@statsig/client-core';
2
2
  type UpdaterArg = StatsigUser | ((previous: StatsigUser) => StatsigUser);
3
3
  type UpdaterFunc<T> = (updated: UpdaterArg) => T;
4
- type SyncUpdateFunc = UpdaterFunc<void>;
5
- type AsyncUpdateFunc = UpdaterFunc<Promise<void>>;
4
+ type SyncUpdateFunc = UpdaterFunc<StatsigUpdateDetails>;
5
+ type AsyncUpdateFunc = UpdaterFunc<Promise<StatsigUpdateDetails>>;
6
6
  export type UseStatsigUserResult = {
7
7
  user: StatsigUser;
8
8
  updateUserSync: SyncUpdateFunc;
@@ -18,7 +18,7 @@ function useStatsigUser() {
18
18
  if (typeof arg === 'function') {
19
19
  arg = arg(memoUser);
20
20
  }
21
- client.updateUserSync(arg);
21
+ return client.updateUserSync(arg);
22
22
  }, deps),
23
23
  updateUserAsync: (0, react_1.useCallback)((arg) => {
24
24
  if (typeof arg === 'function') {