@scaleway/use-growthbook 2.1.9 → 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.
- package/dist/AbTestProvider.cjs +9 -14
- package/dist/AbTestProvider.d.ts +2 -2
- package/dist/AbTestProvider.js +9 -14
- package/dist/index.cjs +2 -6
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -3
- package/dist/types.d.ts +2 -2
- package/dist/useAbTestAttributes.cjs +1 -1
- package/dist/useAbTestAttributes.js +1 -1
- package/package.json +5 -3
package/dist/AbTestProvider.cjs
CHANGED
|
@@ -4,26 +4,17 @@ 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
|
-
|
|
8
|
-
timeout: 500
|
|
9
|
-
skipCache: false
|
|
7
|
+
skipCache: false,
|
|
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
15
|
clientKey,
|
|
23
16
|
enableDevMode,
|
|
24
|
-
trackingCallback
|
|
25
|
-
backgroundSync,
|
|
26
|
-
subscribeToChanges
|
|
17
|
+
trackingCallback
|
|
27
18
|
});
|
|
28
19
|
const AbTestProvider = ({
|
|
29
20
|
children,
|
|
@@ -39,7 +30,11 @@ const AbTestProvider = ({
|
|
|
39
30
|
);
|
|
40
31
|
const loadFeature = react.useCallback(async () => {
|
|
41
32
|
if (config.clientKey) {
|
|
42
|
-
|
|
33
|
+
const initConfig = {
|
|
34
|
+
...defaultLoadConfig,
|
|
35
|
+
...loadConfig
|
|
36
|
+
};
|
|
37
|
+
await growthbook.init(initConfig);
|
|
43
38
|
}
|
|
44
39
|
}, [growthbook, config, loadConfig]);
|
|
45
40
|
react.useEffect(() => {
|
package/dist/AbTestProvider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
2
|
import type { Attributes, ErrorCallback, LoadConfig, ToolConfig, TrackingCallback } from './types';
|
|
3
3
|
type AbTestProviderProps = {
|
|
4
4
|
children: ReactNode;
|
|
@@ -8,5 +8,5 @@ type AbTestProviderProps = {
|
|
|
8
8
|
attributes: Attributes;
|
|
9
9
|
loadConfig?: LoadConfig;
|
|
10
10
|
};
|
|
11
|
-
export declare const AbTestProvider:
|
|
11
|
+
export declare const AbTestProvider: ComponentType<AbTestProviderProps>;
|
|
12
12
|
export {};
|
package/dist/AbTestProvider.js
CHANGED
|
@@ -2,26 +2,17 @@ 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
|
-
|
|
6
|
-
timeout: 500
|
|
7
|
-
skipCache: false
|
|
5
|
+
skipCache: false,
|
|
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
13
|
clientKey,
|
|
21
14
|
enableDevMode,
|
|
22
|
-
trackingCallback
|
|
23
|
-
backgroundSync,
|
|
24
|
-
subscribeToChanges
|
|
15
|
+
trackingCallback
|
|
25
16
|
});
|
|
26
17
|
const AbTestProvider = ({
|
|
27
18
|
children,
|
|
@@ -37,7 +28,11 @@ const AbTestProvider = ({
|
|
|
37
28
|
);
|
|
38
29
|
const loadFeature = useCallback(async () => {
|
|
39
30
|
if (config.clientKey) {
|
|
40
|
-
|
|
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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const growthbookReact = require("@growthbook/growthbook-react");
|
|
4
|
-
const useAbTestAttributes = require("./useAbTestAttributes.cjs");
|
|
5
4
|
const AbTestProvider = require("./AbTestProvider.cjs");
|
|
5
|
+
const useAbTestAttributes = require("./useAbTestAttributes.cjs");
|
|
6
6
|
Object.defineProperty(exports, "FeatureString", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: () => growthbookReact.FeatureString
|
|
@@ -35,13 +35,9 @@ 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
|
|
45
41
|
});
|
|
46
|
-
exports.useAbTestAttributes = useAbTestAttributes.useAbTestAttributes;
|
|
47
42
|
exports.AbTestProvider = AbTestProvider.AbTestProvider;
|
|
43
|
+
exports.useAbTestAttributes = useAbTestAttributes.useAbTestAttributes;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { useExperiment, useFeature,
|
|
2
|
-
export { FeatureString, FeaturesReady, IfFeatureEnabled, } from '@growthbook/growthbook-react';
|
|
3
|
-
export { useAbTestAttributes } from './useAbTestAttributes';
|
|
1
|
+
export { FeatureString, FeaturesReady, IfFeatureEnabled, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, useGrowthBook, withRunExperiment, } from '@growthbook/growthbook-react';
|
|
4
2
|
export { AbTestProvider } from './AbTestProvider';
|
|
5
|
-
export type {
|
|
3
|
+
export type { ErrorCallback, ToolConfig, TrackingCallback } from './types';
|
|
4
|
+
export { useAbTestAttributes } from './useAbTestAttributes';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FeatureString, FeaturesReady, IfFeatureEnabled, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, useGrowthBook,
|
|
2
|
-
import { useAbTestAttributes } from "./useAbTestAttributes.js";
|
|
1
|
+
import { FeatureString, FeaturesReady, IfFeatureEnabled, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, useGrowthBook, withRunExperiment } from "@growthbook/growthbook-react";
|
|
3
2
|
import { AbTestProvider } from "./AbTestProvider.js";
|
|
3
|
+
import { useAbTestAttributes } from "./useAbTestAttributes.js";
|
|
4
4
|
export {
|
|
5
5
|
AbTestProvider,
|
|
6
6
|
FeatureString,
|
|
@@ -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['
|
|
9
|
-
export type ToolConfig = Pick<Context, 'apiHost' | 'clientKey' | 'enableDevMode' | '
|
|
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.
|
|
3
|
+
"version": "2.1.11",
|
|
4
4
|
"description": "Utility package to expose AB test tool",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.x"
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"feature flags"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@growthbook/growthbook-react": "1.
|
|
37
|
+
"@growthbook/growthbook-react": "1.6.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"react": "19.
|
|
40
|
+
"react": "19.2.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": "18.x || 19.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 .",
|