@scaleway/use-growthbook 2.1.12 → 2.1.15

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
@@ -23,7 +23,7 @@ ReactDOM.render(
23
23
  <React.StrictMode>
24
24
  <AbTestProvider
25
25
  config={{ apiHost: 'string', clientKey: 'string', enableDevMode: true }}
26
- anonymousId="123456789"
26
+ anonymousId='123456789'
27
27
  trackingCallback={(experiment, result) => console.log(experiment, result)}
28
28
  errorCallback={console.error}
29
29
  >
@@ -0,0 +1,3 @@
1
+ # Licenses
2
+
3
+ The app does not bundle any dependencies with licenses.
@@ -1,54 +1,59 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const growthbookReact = require("@growthbook/growthbook-react");
5
- const react = require("react");
6
- const defaultLoadConfig = {
7
- skipCache: false,
8
- timeout: 500
1
+ let _growthbook_growthbook_react = require("@growthbook/growthbook-react");
2
+ let react = require("react");
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
+ //#region src/AbTestProvider.tsx
5
+ var defaultLoadConfig = {
6
+ skipCache: false,
7
+ timeout: 500
9
8
  };
10
- const getGrowthBookInstance = ({
11
- config: { apiHost, clientKey, enableDevMode },
12
- trackingCallback
13
- }) => new growthbookReact.GrowthBook({
14
- apiHost,
15
- clientKey,
16
- enableDevMode,
17
- trackingCallback
9
+ var getGrowthBookInstance = ({ config: { apiHost, clientKey, enableDevMode }, trackingCallback }) => new _growthbook_growthbook_react.GrowthBook({
10
+ apiHost,
11
+ clientKey,
12
+ enableDevMode,
13
+ trackingCallback
18
14
  });
19
- const AbTestProvider = ({
20
- children,
21
- config,
22
- trackingCallback,
23
- errorCallback,
24
- attributes,
25
- loadConfig
26
- }) => {
27
- const growthbook = react.useMemo(
28
- () => getGrowthBookInstance({ config, trackingCallback }),
29
- [trackingCallback, config]
30
- );
31
- const loadFeature = react.useCallback(async () => {
32
- if (config.clientKey) {
33
- const initConfig = {
34
- ...defaultLoadConfig,
35
- ...loadConfig
36
- };
37
- await growthbook.init(initConfig);
38
- }
39
- }, [growthbook, config, loadConfig]);
40
- react.useEffect(() => {
41
- loadFeature().catch(errorCallback);
42
- }, [loadFeature, errorCallback]);
43
- react.useEffect(() => {
44
- const currentAttributes = growthbook.getAttributes();
45
- if (currentAttributes !== attributes) {
46
- growthbook.setAttributes({
47
- ...currentAttributes,
48
- ...attributes
49
- }).catch(errorCallback);
50
- }
51
- }, [attributes, growthbook, errorCallback]);
52
- return /* @__PURE__ */ jsxRuntime.jsx(growthbookReact.GrowthBookProvider, { growthbook, children });
15
+ var AbTestProvider = ({ children, config, trackingCallback, errorCallback, attributes, loadConfig }) => {
16
+ const growthbook = (0, react.useMemo)(() => getGrowthBookInstance({
17
+ config,
18
+ trackingCallback
19
+ }), [trackingCallback, config]);
20
+ const loadFeature = (0, react.useCallback)(async () => {
21
+ if (config.clientKey) {
22
+ const initConfig = {
23
+ ...defaultLoadConfig,
24
+ ...loadConfig
25
+ };
26
+ await growthbook.init(initConfig);
27
+ }
28
+ }, [
29
+ growthbook,
30
+ config,
31
+ loadConfig
32
+ ]);
33
+ (0, react.useEffect)(() => {
34
+ loadFeature().catch((error) => {
35
+ if (errorCallback && error instanceof Error) errorCallback(error);
36
+ return null;
37
+ });
38
+ }, [loadFeature, errorCallback]);
39
+ (0, react.useEffect)(() => {
40
+ const currentAttributes = growthbook.getAttributes();
41
+ if (currentAttributes !== attributes) growthbook.setAttributes({
42
+ ...currentAttributes,
43
+ ...attributes
44
+ }).catch((error) => {
45
+ if (errorCallback && error instanceof Error) errorCallback(error);
46
+ return null;
47
+ });
48
+ }, [
49
+ attributes,
50
+ growthbook,
51
+ errorCallback
52
+ ]);
53
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_growthbook_growthbook_react.GrowthBookProvider, {
54
+ growthbook,
55
+ children
56
+ });
53
57
  };
58
+ //#endregion
54
59
  exports.AbTestProvider = AbTestProvider;
@@ -1,54 +1,59 @@
1
- import { jsx } from "react/jsx-runtime";
2
1
  import { GrowthBook, GrowthBookProvider } from "@growthbook/growthbook-react";
3
- import { useMemo, useCallback, useEffect } from "react";
4
- const defaultLoadConfig = {
5
- skipCache: false,
6
- timeout: 500
2
+ import { useCallback, useEffect, useMemo } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/AbTestProvider.tsx
5
+ var defaultLoadConfig = {
6
+ skipCache: false,
7
+ timeout: 500
7
8
  };
8
- const getGrowthBookInstance = ({
9
- config: { apiHost, clientKey, enableDevMode },
10
- trackingCallback
11
- }) => new GrowthBook({
12
- apiHost,
13
- clientKey,
14
- enableDevMode,
15
- trackingCallback
9
+ var getGrowthBookInstance = ({ config: { apiHost, clientKey, enableDevMode }, trackingCallback }) => new GrowthBook({
10
+ apiHost,
11
+ clientKey,
12
+ enableDevMode,
13
+ trackingCallback
16
14
  });
17
- const AbTestProvider = ({
18
- children,
19
- config,
20
- trackingCallback,
21
- errorCallback,
22
- attributes,
23
- loadConfig
24
- }) => {
25
- const growthbook = useMemo(
26
- () => getGrowthBookInstance({ config, trackingCallback }),
27
- [trackingCallback, config]
28
- );
29
- const loadFeature = useCallback(async () => {
30
- if (config.clientKey) {
31
- const initConfig = {
32
- ...defaultLoadConfig,
33
- ...loadConfig
34
- };
35
- await growthbook.init(initConfig);
36
- }
37
- }, [growthbook, config, loadConfig]);
38
- useEffect(() => {
39
- loadFeature().catch(errorCallback);
40
- }, [loadFeature, errorCallback]);
41
- useEffect(() => {
42
- const currentAttributes = growthbook.getAttributes();
43
- if (currentAttributes !== attributes) {
44
- growthbook.setAttributes({
45
- ...currentAttributes,
46
- ...attributes
47
- }).catch(errorCallback);
48
- }
49
- }, [attributes, growthbook, errorCallback]);
50
- return /* @__PURE__ */ jsx(GrowthBookProvider, { growthbook, children });
51
- };
52
- export {
53
- AbTestProvider
15
+ var AbTestProvider = ({ children, config, trackingCallback, errorCallback, attributes, loadConfig }) => {
16
+ const growthbook = useMemo(() => getGrowthBookInstance({
17
+ config,
18
+ trackingCallback
19
+ }), [trackingCallback, config]);
20
+ const loadFeature = useCallback(async () => {
21
+ if (config.clientKey) {
22
+ const initConfig = {
23
+ ...defaultLoadConfig,
24
+ ...loadConfig
25
+ };
26
+ await growthbook.init(initConfig);
27
+ }
28
+ }, [
29
+ growthbook,
30
+ config,
31
+ loadConfig
32
+ ]);
33
+ useEffect(() => {
34
+ loadFeature().catch((error) => {
35
+ if (errorCallback && error instanceof Error) errorCallback(error);
36
+ return null;
37
+ });
38
+ }, [loadFeature, errorCallback]);
39
+ useEffect(() => {
40
+ const currentAttributes = growthbook.getAttributes();
41
+ if (currentAttributes !== attributes) growthbook.setAttributes({
42
+ ...currentAttributes,
43
+ ...attributes
44
+ }).catch((error) => {
45
+ if (errorCallback && error instanceof Error) errorCallback(error);
46
+ return null;
47
+ });
48
+ }, [
49
+ attributes,
50
+ growthbook,
51
+ errorCallback
52
+ ]);
53
+ return /* @__PURE__ */ jsx(GrowthBookProvider, {
54
+ growthbook,
55
+ children
56
+ });
54
57
  };
58
+ //#endregion
59
+ export { AbTestProvider };
package/dist/index.cjs CHANGED
@@ -1,43 +1,60 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const growthbookReact = require("@growthbook/growthbook-react");
4
- const AbTestProvider = require("./AbTestProvider.cjs");
5
- const useAbTestAttributes = require("./useAbTestAttributes.cjs");
2
+ const require_AbTestProvider = require("./AbTestProvider.cjs");
3
+ const require_useAbTestAttributes = require("./useAbTestAttributes.cjs");
4
+ let _growthbook_growthbook_react = require("@growthbook/growthbook-react");
5
+ exports.AbTestProvider = require_AbTestProvider.AbTestProvider;
6
6
  Object.defineProperty(exports, "FeatureString", {
7
- enumerable: true,
8
- get: () => growthbookReact.FeatureString
7
+ enumerable: true,
8
+ get: function() {
9
+ return _growthbook_growthbook_react.FeatureString;
10
+ }
9
11
  });
10
12
  Object.defineProperty(exports, "FeaturesReady", {
11
- enumerable: true,
12
- get: () => growthbookReact.FeaturesReady
13
+ enumerable: true,
14
+ get: function() {
15
+ return _growthbook_growthbook_react.FeaturesReady;
16
+ }
13
17
  });
14
18
  Object.defineProperty(exports, "IfFeatureEnabled", {
15
- enumerable: true,
16
- get: () => growthbookReact.IfFeatureEnabled
19
+ enumerable: true,
20
+ get: function() {
21
+ return _growthbook_growthbook_react.IfFeatureEnabled;
22
+ }
17
23
  });
24
+ exports.useAbTestAttributes = require_useAbTestAttributes.useAbTestAttributes;
18
25
  Object.defineProperty(exports, "useExperiment", {
19
- enumerable: true,
20
- get: () => growthbookReact.useExperiment
26
+ enumerable: true,
27
+ get: function() {
28
+ return _growthbook_growthbook_react.useExperiment;
29
+ }
21
30
  });
22
31
  Object.defineProperty(exports, "useFeature", {
23
- enumerable: true,
24
- get: () => growthbookReact.useFeature
32
+ enumerable: true,
33
+ get: function() {
34
+ return _growthbook_growthbook_react.useFeature;
35
+ }
25
36
  });
26
37
  Object.defineProperty(exports, "useFeatureIsOn", {
27
- enumerable: true,
28
- get: () => growthbookReact.useFeatureIsOn
38
+ enumerable: true,
39
+ get: function() {
40
+ return _growthbook_growthbook_react.useFeatureIsOn;
41
+ }
29
42
  });
30
43
  Object.defineProperty(exports, "useFeatureValue", {
31
- enumerable: true,
32
- get: () => growthbookReact.useFeatureValue
44
+ enumerable: true,
45
+ get: function() {
46
+ return _growthbook_growthbook_react.useFeatureValue;
47
+ }
33
48
  });
34
49
  Object.defineProperty(exports, "useGrowthBook", {
35
- enumerable: true,
36
- get: () => growthbookReact.useGrowthBook
50
+ enumerable: true,
51
+ get: function() {
52
+ return _growthbook_growthbook_react.useGrowthBook;
53
+ }
37
54
  });
38
55
  Object.defineProperty(exports, "withRunExperiment", {
39
- enumerable: true,
40
- get: () => growthbookReact.withRunExperiment
56
+ enumerable: true,
57
+ get: function() {
58
+ return _growthbook_growthbook_react.withRunExperiment;
59
+ }
41
60
  });
42
- exports.AbTestProvider = AbTestProvider.AbTestProvider;
43
- exports.useAbTestAttributes = useAbTestAttributes.useAbTestAttributes;
package/dist/index.js CHANGED
@@ -1,16 +1,4 @@
1
- import { FeatureString, FeaturesReady, IfFeatureEnabled, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, useGrowthBook, withRunExperiment } from "@growthbook/growthbook-react";
2
1
  import { AbTestProvider } from "./AbTestProvider.js";
3
2
  import { useAbTestAttributes } from "./useAbTestAttributes.js";
4
- export {
5
- AbTestProvider,
6
- FeatureString,
7
- FeaturesReady,
8
- IfFeatureEnabled,
9
- useAbTestAttributes,
10
- useExperiment,
11
- useFeature,
12
- useFeatureIsOn,
13
- useFeatureValue,
14
- useGrowthBook,
15
- withRunExperiment
16
- };
3
+ import { FeatureString, FeaturesReady, IfFeatureEnabled, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, useGrowthBook, withRunExperiment } from "@growthbook/growthbook-react";
4
+ export { AbTestProvider, FeatureString, FeaturesReady, IfFeatureEnabled, useAbTestAttributes, useExperiment, useFeature, useFeatureIsOn, useFeatureValue, useGrowthBook, withRunExperiment };
package/dist/types.d.ts CHANGED
@@ -8,4 +8,4 @@ export type Attributes = Record<string, string | number | undefined>;
8
8
  export type LoadConfig = NonNullable<Parameters<GrowthBook['init']>[0]>;
9
9
  export type ToolConfig = Pick<Context, 'apiHost' | 'clientKey' | 'enableDevMode' | 'debug' | 'stickyBucketService'>;
10
10
  export type TrackingCallback = NonNullable<Context['trackingCallback']>;
11
- export type ErrorCallback = (error: Error | string) => void | null;
11
+ export type ErrorCallback = ((error: Error | string) => void) | null;
@@ -1,13 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const growthbookReact = require("@growthbook/growthbook-react");
4
- const useAbTestAttributes = () => {
5
- const growthBook = growthbookReact.useGrowthBook();
6
- const attributes = growthBook.getAttributes();
7
- const setAttributes = async (newAttributes) => growthBook.setAttributes({
8
- ...attributes,
9
- ...newAttributes
10
- });
11
- return [attributes, setAttributes];
1
+ let _growthbook_growthbook_react = require("@growthbook/growthbook-react");
2
+ //#region src/useAbTestAttributes.ts
3
+ var useAbTestAttributes = () => {
4
+ const growthBook = (0, _growthbook_growthbook_react.useGrowthBook)();
5
+ const attributes = growthBook.getAttributes();
6
+ const setAttributes = async (newAttributes) => growthBook.setAttributes({
7
+ ...attributes,
8
+ ...newAttributes
9
+ });
10
+ return [attributes, setAttributes];
12
11
  };
12
+ //#endregion
13
13
  exports.useAbTestAttributes = useAbTestAttributes;
@@ -1,13 +1,13 @@
1
1
  import { useGrowthBook } from "@growthbook/growthbook-react";
2
- const useAbTestAttributes = () => {
3
- const growthBook = useGrowthBook();
4
- const attributes = growthBook.getAttributes();
5
- const setAttributes = async (newAttributes) => growthBook.setAttributes({
6
- ...attributes,
7
- ...newAttributes
8
- });
9
- return [attributes, setAttributes];
10
- };
11
- export {
12
- useAbTestAttributes
2
+ //#region src/useAbTestAttributes.ts
3
+ var useAbTestAttributes = () => {
4
+ const growthBook = useGrowthBook();
5
+ const attributes = growthBook.getAttributes();
6
+ const setAttributes = async (newAttributes) => growthBook.setAttributes({
7
+ ...attributes,
8
+ ...newAttributes
9
+ });
10
+ return [attributes, setAttributes];
13
11
  };
12
+ //#endregion
13
+ export { useAbTestAttributes };
package/package.json CHANGED
@@ -1,13 +1,23 @@
1
1
  {
2
2
  "name": "@scaleway/use-growthbook",
3
- "version": "2.1.12",
3
+ "version": "2.1.15",
4
4
  "description": "Utility package to expose AB test tool",
5
- "engines": {
6
- "node": ">=20.x"
5
+ "keywords": [
6
+ "ab",
7
+ "feature flags"
8
+ ],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/scaleway/scaleway-lib",
13
+ "directory": "packages/growthbook"
7
14
  },
8
- "main": "./dist/index.cjs",
9
- "sideEffects": false,
15
+ "files": [
16
+ "dist/*"
17
+ ],
10
18
  "type": "module",
19
+ "sideEffects": false,
20
+ "main": "./dist/index.cjs",
11
21
  "module": "./dist/index.js",
12
22
  "types": "./dist/index.d.ts",
13
23
  "exports": {
@@ -20,37 +30,24 @@
20
30
  "publishConfig": {
21
31
  "access": "public"
22
32
  },
23
- "files": [
24
- "dist/*"
25
- ],
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/scaleway/scaleway-lib",
29
- "directory": "packages/growthbook"
30
- },
31
- "license": "MIT",
32
- "keywords": [
33
- "ab",
34
- "feature flags"
35
- ],
36
33
  "dependencies": {
37
- "@growthbook/growthbook-react": "1.6.3"
34
+ "@growthbook/growthbook-react": "1.6.5"
38
35
  },
39
36
  "devDependencies": {
40
- "react": "19.2.3"
37
+ "react": "19.2.5"
41
38
  },
42
39
  "peerDependencies": {
43
40
  "react": "18.x || 19.x"
44
41
  },
42
+ "engines": {
43
+ "node": ">=20.x"
44
+ },
45
45
  "scripts": {
46
46
  "prebuild": "shx rm -rf dist",
47
- "typecheck": "tsc --noEmit",
48
- "typecheck:go": "tsgo --noEmit",
49
- "type:generate": "tsc --declaration -p tsconfig.build.json",
50
- "type:generate:go": "tsgo --declaration -p tsconfig.build.json",
47
+ "typecheck": "tsgo --noEmit",
48
+ "type:generate": "tsgo --declaration -p tsconfig.build.json",
51
49
  "build": "vite build --config vite.config.ts && pnpm run type:generate",
52
50
  "build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
53
- "lint": "eslint --report-unused-disable-directives --cache --cache-strategy content --ext ts,tsx .",
54
51
  "test:unit": "vitest --run --config vite.config.ts",
55
52
  "test:unit:coverage": "pnpm test:unit --coverage"
56
53
  }
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Scaleway
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.