@scaleway/use-growthbook 1.0.0 → 1.0.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/CHANGELOG.md +12 -0
- package/dist/AbTestProvider.js +13 -16
- package/dist/index.d.ts +17 -11
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @scaleway/use-growthbook
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1497](https://github.com/scaleway/scaleway-lib/pull/1497) [`252e3e1`](https://github.com/scaleway/scaleway-lib/commit/252e3e1f51f3f164ca2426e4888e6d4322b648a4) Thanks [@renovate](https://github.com/apps/renovate)! - Updated dependency `@growthbook/growthbook-react` to `0.18.0`.
|
|
8
|
+
|
|
9
|
+
## 1.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1439](https://github.com/scaleway/scaleway-lib/pull/1439) [`eaad0f7`](https://github.com/scaleway/scaleway-lib/commit/eaad0f7195dac15e3b7b2b300b481e3fe7b543cf) Thanks [@philibea](https://github.com/philibea)! - add loadfeature configuration into the providers and moove return function from null to void
|
|
14
|
+
|
|
3
15
|
## 1.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/dist/AbTestProvider.js
CHANGED
|
@@ -9,43 +9,40 @@ const getGrowthBookInstance = _ref => {
|
|
|
9
9
|
clientKey,
|
|
10
10
|
enableDevMode
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
attributes,
|
|
13
13
|
trackingCallback
|
|
14
14
|
} = _ref;
|
|
15
15
|
return new GrowthBook({
|
|
16
16
|
apiHost,
|
|
17
17
|
clientKey,
|
|
18
18
|
enableDevMode,
|
|
19
|
-
attributes
|
|
20
|
-
anonymousId,
|
|
21
|
-
userId: undefined,
|
|
22
|
-
organizationId: undefined,
|
|
23
|
-
organizationType: undefined
|
|
24
|
-
},
|
|
19
|
+
attributes,
|
|
25
20
|
trackingCallback
|
|
26
21
|
});
|
|
27
22
|
};
|
|
23
|
+
const defaultLoadConfig = {
|
|
24
|
+
autoRefresh: false,
|
|
25
|
+
timeout: 500
|
|
26
|
+
};
|
|
28
27
|
const AbTestProvider = _ref2 => {
|
|
29
28
|
let {
|
|
30
29
|
children,
|
|
31
30
|
config,
|
|
32
|
-
anonymousId,
|
|
33
31
|
trackingCallback,
|
|
34
|
-
errorCallback
|
|
32
|
+
errorCallback,
|
|
33
|
+
attributes,
|
|
34
|
+
loadConfig = defaultLoadConfig
|
|
35
35
|
} = _ref2;
|
|
36
36
|
const growthbook = useMemo(() => getGrowthBookInstance({
|
|
37
37
|
config,
|
|
38
|
-
|
|
38
|
+
attributes,
|
|
39
39
|
trackingCallback
|
|
40
|
-
}), [trackingCallback, config,
|
|
40
|
+
}), [trackingCallback, config, attributes]);
|
|
41
41
|
const loadFeature = useCallback(async () => {
|
|
42
42
|
if (config.clientKey) {
|
|
43
|
-
await growthbook.loadFeatures(
|
|
44
|
-
autoRefresh: false,
|
|
45
|
-
timeout: 500
|
|
46
|
-
});
|
|
43
|
+
await growthbook.loadFeatures(loadConfig);
|
|
47
44
|
}
|
|
48
|
-
}, [growthbook, config]);
|
|
45
|
+
}, [growthbook, config, loadConfig]);
|
|
49
46
|
useEffect(() => {
|
|
50
47
|
loadFeature().catch(errorCallback);
|
|
51
48
|
}, [loadFeature, errorCallback]);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import { Context } from '@growthbook/growthbook-react';
|
|
2
|
+
export { Context, FeatureString, FeaturesReady, IfFeatureEnabled, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, withRunExperiment } from '@growthbook/growthbook-react';
|
|
2
3
|
import * as react from 'react';
|
|
3
4
|
import { ReactNode } from 'react';
|
|
4
5
|
|
|
5
|
-
type Attributes = Record<string,
|
|
6
|
+
type Attributes = Record<string, string | number | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* @param {boolean} [autoRefresh] - false.
|
|
9
|
+
* @param {number} [timeout] - 500.
|
|
10
|
+
*/
|
|
11
|
+
type LoadConfig = {
|
|
12
|
+
autoRefresh: boolean;
|
|
13
|
+
timeout: number;
|
|
14
|
+
};
|
|
6
15
|
|
|
7
|
-
declare const useAbTestAttributes: () => [Attributes, (attributes: Attributes) =>
|
|
16
|
+
declare const useAbTestAttributes: () => [Attributes, (attributes: Attributes) => void];
|
|
8
17
|
|
|
9
18
|
type ToolConfig = {
|
|
10
19
|
apiHost: string;
|
|
11
20
|
clientKey: string;
|
|
12
21
|
enableDevMode: boolean;
|
|
13
22
|
};
|
|
14
|
-
type TrackingCallback =
|
|
15
|
-
key: string;
|
|
16
|
-
}, result: {
|
|
17
|
-
key: string;
|
|
18
|
-
}) => null;
|
|
23
|
+
type TrackingCallback = NonNullable<Context['trackingCallback']>;
|
|
19
24
|
type AbTestProviderProps = {
|
|
20
25
|
children: ReactNode;
|
|
21
|
-
anonymousId: string;
|
|
22
26
|
config: ToolConfig;
|
|
23
27
|
trackingCallback: TrackingCallback;
|
|
24
|
-
errorCallback: (error: string) =>
|
|
28
|
+
errorCallback: (error: Error | string) => void;
|
|
29
|
+
attributes: Attributes;
|
|
30
|
+
loadConfig?: LoadConfig;
|
|
25
31
|
};
|
|
26
|
-
declare const AbTestProvider: ({ children, config,
|
|
32
|
+
declare const AbTestProvider: ({ children, config, trackingCallback, errorCallback, attributes, loadConfig, }: AbTestProviderProps) => react.JSX.Element;
|
|
27
33
|
|
|
28
34
|
export { AbTestProvider, useAbTestAttributes };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { useExperiment, useFeature, useFeatureIsOn, useFeatureValue, withRunExperiment } from '@growthbook/growthbook-react';
|
|
2
2
|
export { useAbTestAttributes } from './useAbTestAttributes.js';
|
|
3
3
|
export { AbTestProvider } from './AbTestProvider.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleway/use-growthbook",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Utility package to expose AB test tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"feature flags"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@growthbook/growthbook-react": "0.
|
|
28
|
+
"@growthbook/growthbook-react": "0.18.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"react": "18.2.0"
|