@scaleway/use-growthbook 2.1.10 → 2.1.11

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.
@@ -4,25 +4,16 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const growthbookReact = require("@growthbook/growthbook-react");
5
5
  const react = require("react");
6
6
  const defaultLoadConfig = {
7
- autoRefresh: false,
8
7
  skipCache: false,
9
8
  timeout: 500
10
9
  };
11
10
  const getGrowthBookInstance = ({
12
- config: {
13
- apiHost,
14
- clientKey,
15
- enableDevMode,
16
- backgroundSync,
17
- subscribeToChanges
18
- },
11
+ config: { apiHost, clientKey, enableDevMode },
19
12
  trackingCallback
20
13
  }) => new growthbookReact.GrowthBook({
21
14
  apiHost,
22
- backgroundSync,
23
15
  clientKey,
24
16
  enableDevMode,
25
- subscribeToChanges,
26
17
  trackingCallback
27
18
  });
28
19
  const AbTestProvider = ({
@@ -39,7 +30,11 @@ const AbTestProvider = ({
39
30
  );
40
31
  const loadFeature = react.useCallback(async () => {
41
32
  if (config.clientKey) {
42
- await growthbook.loadFeatures(loadConfig ?? defaultLoadConfig);
33
+ const initConfig = {
34
+ ...defaultLoadConfig,
35
+ ...loadConfig
36
+ };
37
+ await growthbook.init(initConfig);
43
38
  }
44
39
  }, [growthbook, config, loadConfig]);
45
40
  react.useEffect(() => {
@@ -2,25 +2,16 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { GrowthBook, GrowthBookProvider } from "@growthbook/growthbook-react";
3
3
  import { useMemo, useCallback, useEffect } from "react";
4
4
  const defaultLoadConfig = {
5
- autoRefresh: false,
6
5
  skipCache: false,
7
6
  timeout: 500
8
7
  };
9
8
  const getGrowthBookInstance = ({
10
- config: {
11
- apiHost,
12
- clientKey,
13
- enableDevMode,
14
- backgroundSync,
15
- subscribeToChanges
16
- },
9
+ config: { apiHost, clientKey, enableDevMode },
17
10
  trackingCallback
18
11
  }) => new GrowthBook({
19
12
  apiHost,
20
- backgroundSync,
21
13
  clientKey,
22
14
  enableDevMode,
23
- subscribeToChanges,
24
15
  trackingCallback
25
16
  });
26
17
  const AbTestProvider = ({
@@ -37,7 +28,11 @@ const AbTestProvider = ({
37
28
  );
38
29
  const loadFeature = useCallback(async () => {
39
30
  if (config.clientKey) {
40
- await growthbook.loadFeatures(loadConfig ?? defaultLoadConfig);
31
+ const initConfig = {
32
+ ...defaultLoadConfig,
33
+ ...loadConfig
34
+ };
35
+ await growthbook.init(initConfig);
41
36
  }
42
37
  }, [growthbook, config, loadConfig]);
43
38
  useEffect(() => {
package/dist/index.cjs CHANGED
@@ -35,10 +35,6 @@ Object.defineProperty(exports, "useGrowthBook", {
35
35
  enumerable: true,
36
36
  get: () => growthbookReact.useGrowthBook
37
37
  });
38
- Object.defineProperty(exports, "useGrowthBookSSR", {
39
- enumerable: true,
40
- get: () => growthbookReact.useGrowthBookSSR
41
- });
42
38
  Object.defineProperty(exports, "withRunExperiment", {
43
39
  enumerable: true,
44
40
  get: () => growthbookReact.withRunExperiment
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { FeatureString, FeaturesReady, IfFeatureEnabled, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, useGrowthBook, useGrowthBookSSR, withRunExperiment, } from '@growthbook/growthbook-react';
1
+ export { FeatureString, FeaturesReady, IfFeatureEnabled, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, useGrowthBook, withRunExperiment, } from '@growthbook/growthbook-react';
2
2
  export { AbTestProvider } from './AbTestProvider';
3
3
  export type { ErrorCallback, ToolConfig, TrackingCallback } from './types';
4
4
  export { useAbTestAttributes } from './useAbTestAttributes';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FeatureString, FeaturesReady, IfFeatureEnabled, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, useGrowthBook, useGrowthBookSSR, withRunExperiment } from "@growthbook/growthbook-react";
1
+ import { FeatureString, FeaturesReady, IfFeatureEnabled, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, useGrowthBook, withRunExperiment } from "@growthbook/growthbook-react";
2
2
  import { AbTestProvider } from "./AbTestProvider.js";
3
3
  import { useAbTestAttributes } from "./useAbTestAttributes.js";
4
4
  export {
@@ -12,6 +12,5 @@ export {
12
12
  useFeatureIsOn,
13
13
  useFeatureValue,
14
14
  useGrowthBook,
15
- useGrowthBookSSR,
16
15
  withRunExperiment
17
16
  };
package/dist/types.d.ts CHANGED
@@ -5,7 +5,7 @@ export type Attributes = Record<string, string | number | undefined>;
5
5
  * @param {number} [timeout] - 500.
6
6
  * @param {boolean} [skipCache] - false.
7
7
  */
8
- export type LoadConfig = NonNullable<Parameters<GrowthBook['loadFeatures']>[0]>;
9
- export type ToolConfig = Pick<Context, 'apiHost' | 'clientKey' | 'enableDevMode' | 'backgroundSync' | 'subscribeToChanges'>;
8
+ export type LoadConfig = NonNullable<Parameters<GrowthBook['init']>[0]>;
9
+ export type ToolConfig = Pick<Context, 'apiHost' | 'clientKey' | 'enableDevMode' | 'debug' | 'stickyBucketService'>;
10
10
  export type TrackingCallback = NonNullable<Context['trackingCallback']>;
11
11
  export type ErrorCallback = (error: Error | string) => void | null;
@@ -4,7 +4,7 @@ const growthbookReact = require("@growthbook/growthbook-react");
4
4
  const useAbTestAttributes = () => {
5
5
  const growthBook = growthbookReact.useGrowthBook();
6
6
  const attributes = growthBook.getAttributes();
7
- const setAttributes = (newAttributes) => growthBook.setAttributes({
7
+ const setAttributes = async (newAttributes) => growthBook.setAttributes({
8
8
  ...attributes,
9
9
  ...newAttributes
10
10
  });
@@ -2,7 +2,7 @@ import { useGrowthBook } from "@growthbook/growthbook-react";
2
2
  const useAbTestAttributes = () => {
3
3
  const growthBook = useGrowthBook();
4
4
  const attributes = growthBook.getAttributes();
5
- const setAttributes = (newAttributes) => growthBook.setAttributes({
5
+ const setAttributes = async (newAttributes) => growthBook.setAttributes({
6
6
  ...attributes,
7
7
  ...newAttributes
8
8
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/use-growthbook",
3
- "version": "2.1.10",
3
+ "version": "2.1.11",
4
4
  "description": "Utility package to expose AB test tool",
5
5
  "engines": {
6
6
  "node": ">=20.x"
@@ -45,7 +45,9 @@
45
45
  "scripts": {
46
46
  "prebuild": "shx rm -rf dist",
47
47
  "typecheck": "tsc --noEmit",
48
+ "typecheck:go": "tsgo --noEmit",
48
49
  "type:generate": "tsc --declaration -p tsconfig.build.json",
50
+ "type:generate:go": "tsgo --declaration -p tsconfig.build.json",
49
51
  "build": "vite build --config vite.config.ts && pnpm run type:generate",
50
52
  "build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
51
53
  "lint": "eslint --report-unused-disable-directives --cache --cache-strategy content --ext ts,tsx .",