@statsig/react-bindings 2.1.0 → 2.1.1-beta.2

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
@@ -1,3 +1,5 @@
1
+ Statsig helps you move faster with feature gates (feature flags), and/or dynamic configs. It also allows you to run A/B/n tests to validate your new features and understand their impact on your KPIs. If you're new to Statsig, check out our product and create an account at [statsig.com](https://www.statsig.com/?ref=gh_jsm).
2
+
1
3
  <h1 align="center">
2
4
  <a href="https://statsig.com/?ref=gh_jsm">
3
5
  <img src="https://github.com/statsig-io/js-client-monorepo/assets/95646168/ae5499ed-20ff-4584-bf21-8857f800d485" />
@@ -18,8 +20,6 @@
18
20
  </a>
19
21
  </p>
20
22
 
21
- Statsig helps you move faster with feature gates (feature flags), and/or dynamic configs. It also allows you to run A/B/n tests to validate your new features and understand their impact on your KPIs. If you're new to Statsig, check out our product and create an account at [statsig.com](https://www.statsig.com/?ref=gh_jsm).
22
-
23
23
  ## Getting Started
24
24
 
25
25
  Read through the [Documentation](https://docs.statsig.com/client/javascript-sdk?ref=gh_jsm) or check out the [Samples](samples/).
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@statsig/react-bindings",
3
- "version": "2.1.0",
3
+ "version": "2.1.1-beta.2",
4
4
  "dependencies": {
5
- "@statsig/client-core": "2.1.0"
5
+ "@statsig/client-core": "2.1.1-beta.2"
6
6
  },
7
7
  "peerDependencies": {
8
8
  "react": "^16.6.3 || ^17.0.0 || ^18.0.0"
9
9
  },
10
10
  "optionalDependencies": {
11
- "@statsig/js-client": "2.1.0",
12
- "@statsig/js-on-device-eval-client": "2.1.0"
11
+ "@statsig/js-client": "2.1.1-beta.2",
12
+ "@statsig/js-on-device-eval-client": "2.1.1-beta.2"
13
13
  },
14
14
  "type": "commonjs",
15
15
  "main": "./src/index.js",
@@ -1,12 +1,14 @@
1
1
  import { ReactNode } from 'react';
2
- import { AnyStatsigOptions, StatsigClientInterface, StatsigUser } from '@statsig/client-core';
2
+ import { StatsigUser } from '@statsig/client-core';
3
+ import type { StatsigClient, StatsigOptions } from '@statsig/js-client';
4
+ import type { StatsigOnDeviceEvalClient, StatsigOptions as StatsigOptionsOnDeviceEval } from '@statsig/js-on-device-eval-client';
3
5
  type WithClient = {
4
- client: StatsigClientInterface;
6
+ client: StatsigClient | StatsigOnDeviceEvalClient;
5
7
  };
6
8
  type WithConfiguration = {
7
9
  sdkKey: string;
8
10
  user: StatsigUser;
9
- options?: AnyStatsigOptions;
11
+ options?: StatsigOptionsOnDeviceEval | StatsigOptions;
10
12
  };
11
13
  export type StatsigProviderProps = {
12
14
  children: ReactNode | ReactNode[];
@@ -1,3 +1,5 @@
1
- import { AnyStatsigOptions, OnDeviceEvaluationsInterface, PrecomputedEvaluationsInterface, StatsigUser } from '@statsig/client-core';
2
- export declare function requireOptionalClientDependency(sdkKey: string, initialUser: StatsigUser, statsigOptions: AnyStatsigOptions | null): PrecomputedEvaluationsInterface;
3
- export declare function requireOptionalOnDeviceClientDependency(sdkKey: string, statsigOptions: AnyStatsigOptions | null): OnDeviceEvaluationsInterface;
1
+ import { AnyStatsigOptions, StatsigUser } from '@statsig/client-core';
2
+ import type { StatsigClient as TStatsigClient } from '@statsig/js-client';
3
+ import type { StatsigOnDeviceEvalClient as TStatsigOnDeviceEvalClient } from '@statsig/js-on-device-eval-client';
4
+ export declare function requireOptionalClientDependency(sdkKey: string, initialUser: StatsigUser, statsigOptions: AnyStatsigOptions | null): TStatsigClient;
5
+ export declare function requireOptionalOnDeviceClientDependency(sdkKey: string, statsigOptions: AnyStatsigOptions | null): TStatsigOnDeviceEvalClient;
@@ -3,15 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireOptionalOnDeviceClientDependency = exports.requireOptionalClientDependency = void 0;
4
4
  const client_core_1 = require("@statsig/client-core");
5
5
  const NoopEvaluationsClient_1 = require("./NoopEvaluationsClient");
6
+ let jsClientMod = null;
7
+ try {
8
+ // import {StatsigClient} from '@statsig/js-client';
9
+ // jsClientMod = {StatsigClient};
10
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
11
+ jsClientMod = require('@statsig/js-client');
12
+ }
13
+ catch (error) {
14
+ // noop
15
+ }
16
+ let jsOnDeviceEvalClientMod = null;
17
+ try {
18
+ jsOnDeviceEvalClientMod =
19
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
20
+ require('@statsig/js-on-device-eval-client');
21
+ }
22
+ catch (error) {
23
+ // noop
24
+ }
6
25
  function requireOptionalClientDependency(sdkKey, initialUser, statsigOptions) {
7
26
  let client;
8
- try {
9
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
10
- const mod = require('@statsig/js-client');
11
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
12
- client = new mod.StatsigClient(sdkKey, initialUser, statsigOptions);
27
+ if (jsClientMod) {
28
+ const { StatsigClient } = jsClientMod;
29
+ client = new StatsigClient(sdkKey, initialUser, statsigOptions);
13
30
  }
14
- catch (error) {
31
+ else {
15
32
  client = NoopEvaluationsClient_1.NoopEvaluationsClient;
16
33
  client_core_1.Log.error('Failed to load StatsigClient. Do you have @statsig/js-client installed?');
17
34
  }
@@ -20,15 +37,13 @@ function requireOptionalClientDependency(sdkKey, initialUser, statsigOptions) {
20
37
  exports.requireOptionalClientDependency = requireOptionalClientDependency;
21
38
  function requireOptionalOnDeviceClientDependency(sdkKey, statsigOptions) {
22
39
  let client;
23
- try {
24
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
25
- const mod = require('@statsig/js-on-device-eval-client');
26
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
27
- client = new mod.StatsigOnDeviceEvalClient(sdkKey, statsigOptions);
40
+ if (jsOnDeviceEvalClientMod) {
41
+ const { StatsigOnDeviceEvalClient } = jsOnDeviceEvalClientMod;
42
+ client = new StatsigOnDeviceEvalClient(sdkKey, statsigOptions);
28
43
  }
29
- catch (error) {
44
+ else {
30
45
  client = NoopEvaluationsClient_1.NoopEvaluationsClient;
31
- client_core_1.Log.error('Failed to load StatsigClient. Do you have @statsig/js-on-device-eval-client installed?');
46
+ client_core_1.Log.error('Failed to load StatsigOnDeviceEvalClient. Do you have @statsig/js-on-device-eval-client installed?');
32
47
  }
33
48
  return client;
34
49
  }
@@ -1,5 +1,6 @@
1
- import { AnyStatsigOptions, PrecomputedEvaluationsInterface, StatsigUser } from '@statsig/client-core';
1
+ import { AnyStatsigOptions, StatsigUser } from '@statsig/client-core';
2
+ import type { StatsigClient } from '@statsig/js-client';
2
3
  export declare function useClientAsyncInit(sdkKey: string, initialUser: StatsigUser, statsigOptions?: AnyStatsigOptions | null): {
3
4
  isLoading: boolean;
4
- client: PrecomputedEvaluationsInterface;
5
+ client: StatsigClient;
5
6
  };
@@ -1,4 +1,5 @@
1
- import { AnyStatsigOptions, PrecomputedEvaluationsInterface, StatsigUser } from '@statsig/client-core';
1
+ import { AnyStatsigOptions, StatsigUser } from '@statsig/client-core';
2
+ import type { StatsigClient } from '@statsig/js-client';
2
3
  export declare function useClientBootstrapInit(sdkKey: string, initialUser: StatsigUser, initialValues: string, statsigOptions?: AnyStatsigOptions | null): {
3
- client: PrecomputedEvaluationsInterface;
4
+ client: StatsigClient;
4
5
  };
@@ -1,5 +1,6 @@
1
- import { AnyStatsigOptions, OnDeviceEvaluationsInterface } from '@statsig/client-core';
1
+ import { AnyStatsigOptions } from '@statsig/client-core';
2
+ import type { StatsigOnDeviceEvalClient } from '@statsig/js-on-device-eval-client';
2
3
  export declare function useOnDeviceClientAsyncInit(sdkKey: string, statsigOptions?: AnyStatsigOptions | null): {
3
4
  isLoading: boolean;
4
- client: OnDeviceEvaluationsInterface;
5
+ client: StatsigOnDeviceEvalClient;
5
6
  };