@scaleway/use-growthbook 2.1.12 → 2.1.14

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.
@@ -0,0 +1,3 @@
1
+ # Licenses
2
+
3
+ The app does not bundle any dependencies with licenses.
@@ -1,54 +1,51 @@
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
+ var defaultLoadConfig = {
5
+ skipCache: false,
6
+ timeout: 500
9
7
  };
10
- const getGrowthBookInstance = ({
11
- config: { apiHost, clientKey, enableDevMode },
12
- trackingCallback
13
- }) => new growthbookReact.GrowthBook({
14
- apiHost,
15
- clientKey,
16
- enableDevMode,
17
- trackingCallback
8
+ var getGrowthBookInstance = ({ config: { apiHost, clientKey, enableDevMode }, trackingCallback }) => new _growthbook_growthbook_react.GrowthBook({
9
+ apiHost,
10
+ clientKey,
11
+ enableDevMode,
12
+ trackingCallback
18
13
  });
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 });
14
+ const AbTestProvider = ({ children, config, trackingCallback, errorCallback, attributes, loadConfig }) => {
15
+ const growthbook = (0, react.useMemo)(() => getGrowthBookInstance({
16
+ config,
17
+ trackingCallback
18
+ }), [trackingCallback, config]);
19
+ const loadFeature = (0, react.useCallback)(async () => {
20
+ if (config.clientKey) {
21
+ const initConfig = {
22
+ ...defaultLoadConfig,
23
+ ...loadConfig
24
+ };
25
+ await growthbook.init(initConfig);
26
+ }
27
+ }, [
28
+ growthbook,
29
+ config,
30
+ loadConfig
31
+ ]);
32
+ (0, react.useEffect)(() => {
33
+ loadFeature().catch(errorCallback);
34
+ }, [loadFeature, errorCallback]);
35
+ (0, react.useEffect)(() => {
36
+ const currentAttributes = growthbook.getAttributes();
37
+ if (currentAttributes !== attributes) growthbook.setAttributes({
38
+ ...currentAttributes,
39
+ ...attributes
40
+ }).catch(errorCallback);
41
+ }, [
42
+ attributes,
43
+ growthbook,
44
+ errorCallback
45
+ ]);
46
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_growthbook_growthbook_react.GrowthBookProvider, {
47
+ growthbook,
48
+ children
49
+ });
53
50
  };
54
51
  exports.AbTestProvider = AbTestProvider;
@@ -1,54 +1,51 @@
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
+ var defaultLoadConfig = {
5
+ skipCache: false,
6
+ timeout: 500
7
7
  };
8
- const getGrowthBookInstance = ({
9
- config: { apiHost, clientKey, enableDevMode },
10
- trackingCallback
11
- }) => new GrowthBook({
12
- apiHost,
13
- clientKey,
14
- enableDevMode,
15
- trackingCallback
8
+ var getGrowthBookInstance = ({ config: { apiHost, clientKey, enableDevMode }, trackingCallback }) => new GrowthBook({
9
+ apiHost,
10
+ clientKey,
11
+ enableDevMode,
12
+ trackingCallback
16
13
  });
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
14
+ const AbTestProvider = ({ children, config, trackingCallback, errorCallback, attributes, loadConfig }) => {
15
+ const growthbook = useMemo(() => getGrowthBookInstance({
16
+ config,
17
+ trackingCallback
18
+ }), [trackingCallback, config]);
19
+ const loadFeature = useCallback(async () => {
20
+ if (config.clientKey) {
21
+ const initConfig = {
22
+ ...defaultLoadConfig,
23
+ ...loadConfig
24
+ };
25
+ await growthbook.init(initConfig);
26
+ }
27
+ }, [
28
+ growthbook,
29
+ config,
30
+ loadConfig
31
+ ]);
32
+ useEffect(() => {
33
+ loadFeature().catch(errorCallback);
34
+ }, [loadFeature, errorCallback]);
35
+ useEffect(() => {
36
+ const currentAttributes = growthbook.getAttributes();
37
+ if (currentAttributes !== attributes) growthbook.setAttributes({
38
+ ...currentAttributes,
39
+ ...attributes
40
+ }).catch(errorCallback);
41
+ }, [
42
+ attributes,
43
+ growthbook,
44
+ errorCallback
45
+ ]);
46
+ return /* @__PURE__ */ jsx(GrowthBookProvider, {
47
+ growthbook,
48
+ children
49
+ });
54
50
  };
51
+ 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 };
@@ -1,13 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const growthbookReact = require("@growthbook/growthbook-react");
1
+ let _growthbook_growthbook_react = require("@growthbook/growthbook-react");
4
2
  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];
3
+ const growthBook = (0, _growthbook_growthbook_react.useGrowthBook)();
4
+ const attributes = growthBook.getAttributes();
5
+ const setAttributes = async (newAttributes) => growthBook.setAttributes({
6
+ ...attributes,
7
+ ...newAttributes
8
+ });
9
+ return [attributes, setAttributes];
12
10
  };
13
11
  exports.useAbTestAttributes = useAbTestAttributes;
@@ -1,13 +1,11 @@
1
1
  import { useGrowthBook } from "@growthbook/growthbook-react";
2
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
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];
13
10
  };
11
+ export { useAbTestAttributes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/use-growthbook",
3
- "version": "2.1.12",
3
+ "version": "2.1.14",
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.6.3"
37
+ "@growthbook/growthbook-react": "1.6.4"
38
38
  },
39
39
  "devDependencies": {
40
- "react": "19.2.3"
40
+ "react": "19.2.4"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": "18.x || 19.x"
@@ -50,7 +50,6 @@
50
50
  "type:generate:go": "tsgo --declaration -p tsconfig.build.json",
51
51
  "build": "vite build --config vite.config.ts && pnpm run type:generate",
52
52
  "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
53
  "test:unit": "vitest --run --config vite.config.ts",
55
54
  "test:unit:coverage": "pnpm test:unit --coverage"
56
55
  }
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.