@kameleoon/react-sdk 9.1.0 → 9.2.0
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 +11 -0
- package/dist/createClient.js +1 -1
- package/dist/interfaces/useFeatureFlag.d.ts +18 -1
- package/dist/interfaces/useFeatureFlag.js.map +1 -1
- package/dist/useFeatureFlag.d.ts +1 -0
- package/dist/useFeatureFlag.js +1 -1
- package/dist/useFeatureFlag.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.2.0 (2024-05-07)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- New method [`getActiveFeatureFlags`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/reactjs-sdk/#getactivefeatureflags) obtained with `useFeature` hook, which retrieves feature flags that are active for visitor with detailed variation and variables information.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @kameleoon/javascript-sdk@3.2.0
|
|
13
|
+
|
|
3
14
|
## 9.1.0 (2024-04-19)
|
|
4
15
|
|
|
5
16
|
### Features
|
package/dist/createClient.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _javascriptSdk=require("@kameleoon/javascript-sdk");Object.defineProperty(exports,"__esModule",{value:!0}),exports.createClient=createClient;function createClient(a){let{siteCode:b,configuration:c,externals:d}=a;const e=new _javascriptSdk.KameleoonClient({siteCode:b,configuration:c,externals:d,_internals:{type:_javascriptSdk.SdkLanguageType.REACT,version:"9.
|
|
1
|
+
"use strict";var _javascriptSdk=require("@kameleoon/javascript-sdk");Object.defineProperty(exports,"__esModule",{value:!0}),exports.createClient=createClient;function createClient(a){let{siteCode:b,configuration:c,externals:d}=a;const e=new _javascriptSdk.KameleoonClient({siteCode:b,configuration:c,externals:d,_internals:{type:_javascriptSdk.SdkLanguageType.REACT,version:"9.2.0"}});return e}
|
|
2
2
|
//# sourceMappingURL=createClient.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FeatureFlagType, FeatureFlagVariableType, FeatureVariableResultType, GetFeatureFlagVariableParamsType } from '@kameleoon/javascript-sdk';
|
|
1
|
+
import { FeatureFlagType, KameleoonVariationType, FeatureFlagVariableType, FeatureVariableResultType, GetFeatureFlagVariableParamsType } from '@kameleoon/javascript-sdk';
|
|
2
2
|
export default interface IUseFeatureFlag {
|
|
3
3
|
/**
|
|
4
4
|
* Indicates whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.
|
|
@@ -61,6 +61,23 @@ export default interface IUseFeatureFlag {
|
|
|
61
61
|
* - `KameleoonException.NotTargeted` - Current visitor is not targeted.
|
|
62
62
|
*/
|
|
63
63
|
getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];
|
|
64
|
+
/**
|
|
65
|
+
* @method getActiveFeatureFlags - method collecting all active feature flags information including it's variation and variables for the visitor
|
|
66
|
+
*
|
|
67
|
+
* Note: This method **doesn't send** tracking data
|
|
68
|
+
*
|
|
69
|
+
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
|
|
70
|
+
* @returns {Map<string, KameleoonVariationType>} a map of feature flags with `featureKey` as a key and `KameleoonVariationType` as a value
|
|
71
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
72
|
+
*
|
|
73
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
74
|
+
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
75
|
+
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
|
|
76
|
+
* - `KameleoonException.StorageRead` - Couldn't read storage data
|
|
77
|
+
* - `KameleoonException.JSONParse` - Couldn't parse JSON value
|
|
78
|
+
* - `KameleoonException.NumberParse` - Couldn't parse Number value
|
|
79
|
+
*/
|
|
80
|
+
getActiveFeatureFlags: (visitorCode: string) => Map<string, KameleoonVariationType>;
|
|
64
81
|
/**
|
|
65
82
|
* Returns a list of feature flags stored in the client configuration.
|
|
66
83
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFeatureFlag.js","names":[],"sources":["../../src/interfaces/useFeatureFlag.ts"],"sourcesContent":["import {\n FeatureFlagType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n GetFeatureFlagVariableParamsType,\n} from '@kameleoon/javascript-sdk';\n\nexport default interface IUseFeatureFlag {\n /**\n * Indicates whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @param {string} featureKey - a unique key for feature flag.\n * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`.\n * - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n */\n isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;\n /**\n * Returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @param {string} featureKey - a unique key for feature flag.\n * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string;\n /**\n * Returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {GetFeatureFlagVariableParamsType} params - `visitorCode`, `featureKey` and `variableKey` parameters to return variable.\n * @return {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`.\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value.\n * - `KameleoonException.NumberParse` - Couldn't pass Number value.\n */\n getFeatureFlagVariable: (\n params: GetFeatureFlagVariableParamsType,\n ) => FeatureFlagVariableType;\n /**\n * Returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n /**\n * Returns a list of feature flags stored in the client configuration.\n *\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n */\n getFeatureFlags: () => FeatureFlagType[];\n /**\n * Returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters.\n * @param {string} featureKey - a unique key for feature flag.\n * @return {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value\n * - `KameleoonException.NumberParse` - Couldn't pass Number value\n */\n getFeatureFlagVariables: (\n visitorCode: string,\n featureKey: string,\n ) => FeatureVariableResultType[];\n /**\n * Returns Kameleoon tracking code for the current visitor. Tracking code is built of the feature flag variations that were assigned during the last 5 seconds.\n * See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {string} Kameleoon tracking code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getEngineTrackingCode: (visitorCode: string) => string;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"useFeatureFlag.js","names":[],"sources":["../../src/interfaces/useFeatureFlag.ts"],"sourcesContent":["import {\n FeatureFlagType,\n KameleoonVariationType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n GetFeatureFlagVariableParamsType,\n} from '@kameleoon/javascript-sdk';\n\nexport default interface IUseFeatureFlag {\n /**\n * Indicates whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @param {string} featureKey - a unique key for feature flag.\n * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`.\n * - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n */\n isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;\n /**\n * Returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @param {string} featureKey - a unique key for feature flag.\n * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string;\n /**\n * Returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {GetFeatureFlagVariableParamsType} params - `visitorCode`, `featureKey` and `variableKey` parameters to return variable.\n * @return {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`.\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value.\n * - `KameleoonException.NumberParse` - Couldn't pass Number value.\n */\n getFeatureFlagVariable: (\n params: GetFeatureFlagVariableParamsType,\n ) => FeatureFlagVariableType;\n /**\n * Returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n /**\n * @method getActiveFeatureFlags - method collecting all active feature flags information including it's variation and variables for the visitor\n *\n * Note: This method **doesn't send** tracking data\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {Map<string, KameleoonVariationType>} a map of feature flags with `featureKey` as a key and `KameleoonVariationType` as a value\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getActiveFeatureFlags: (\n visitorCode: string,\n ) => Map<string, KameleoonVariationType>;\n /**\n * Returns a list of feature flags stored in the client configuration.\n *\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n */\n getFeatureFlags: () => FeatureFlagType[];\n /**\n * Returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request.\n *\n * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters.\n * @param {string} featureKey - a unique key for feature flag.\n * @return {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value\n * - `KameleoonException.NumberParse` - Couldn't pass Number value\n */\n getFeatureFlagVariables: (\n visitorCode: string,\n featureKey: string,\n ) => FeatureVariableResultType[];\n /**\n * Returns Kameleoon tracking code for the current visitor. Tracking code is built of the feature flag variations that were assigned during the last 5 seconds.\n * See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {string} Kameleoon tracking code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getEngineTrackingCode: (visitorCode: string) => string;\n}\n"],"mappings":""}
|
package/dist/useFeatureFlag.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import IUseFeatureFlag from './interfaces/useFeatureFlag';
|
|
|
8
8
|
* - `getFeatureFlagVariationKey`,
|
|
9
9
|
* - `getFeatureFlagVariable`,
|
|
10
10
|
* - `getVisitorFeatureFlags`,
|
|
11
|
+
* - `getActiveFeatureFlags`,
|
|
11
12
|
* - `getFeatureFlags`,
|
|
12
13
|
* - `getFeatureFlagVariables`,
|
|
13
14
|
* - `getEngineTrackingCode`
|
package/dist/useFeatureFlag.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFeatureFlag=useFeatureFlag;var _react=require("react"),_useKameleoon=require("./useKameleoon");function useFeatureFlag(){const a=(0,_useKameleoon.useKameleoon)(),b=(0,_react.useCallback)((b,c)=>a.isFeatureFlagActive(b,c),[a]),c=(0,_react.useCallback)((b,c)=>a.getFeatureFlagVariationKey(b,c),[a]),d=(0,_react.useCallback)(b=>{let{visitorCode:c,featureKey:d,variableKey:e}=b;return a.getFeatureFlagVariable({visitorCode:c,featureKey:d,variableKey:e})},[a]),e=(0,_react.useCallback)(b=>a.getVisitorFeatureFlags(b),[a]),f=(0,_react.useCallback)(()=>a.getFeatureFlags(),[a]),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFeatureFlag=useFeatureFlag;var _react=require("react"),_useKameleoon=require("./useKameleoon");function useFeatureFlag(){const a=(0,_useKameleoon.useKameleoon)(),b=(0,_react.useCallback)((b,c)=>a.isFeatureFlagActive(b,c),[a]),c=(0,_react.useCallback)((b,c)=>a.getFeatureFlagVariationKey(b,c),[a]),d=(0,_react.useCallback)(b=>{let{visitorCode:c,featureKey:d,variableKey:e}=b;return a.getFeatureFlagVariable({visitorCode:c,featureKey:d,variableKey:e})},[a]),e=(0,_react.useCallback)(b=>a.getVisitorFeatureFlags(b),[a]),f=(0,_react.useCallback)(b=>a.getActiveFeatureFlags(b),[a]),g=(0,_react.useCallback)(()=>a.getFeatureFlags(),[a]),h=(0,_react.useCallback)((b,c)=>a.getFeatureFlagVariables(b,c),[a]),i=(0,_react.useCallback)(b=>a.getEngineTrackingCode(b),[a]);return{getActiveFeatureFlags:f,getFeatureFlags:g,isFeatureFlagActive:b,getEngineTrackingCode:i,getVisitorFeatureFlags:e,getFeatureFlagVariable:d,getFeatureFlagVariables:h,getFeatureFlagVariationKey:c}}
|
|
2
2
|
//# sourceMappingURL=useFeatureFlag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFeatureFlag.js","names":["useFeatureFlag","client","useKameleoon","isFeatureFlagActive","useCallback","visitorCode","featureKey","getFeatureFlagVariationKey","getFeatureFlagVariable","b","variableKey","getVisitorFeatureFlags","getFeatureFlags","getFeatureFlagVariables","getEngineTrackingCode"],"sources":["../src/useFeatureFlag.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport IUseFeatureFlag from './interfaces/useFeatureFlag';\nimport { useKameleoon } from './useKameleoon';\nimport {\n FeatureFlagType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n GetFeatureFlagVariableParamsType,\n} from '@kameleoon/javascript-sdk';\n\n/**\n * A React Hook that returns methods related to SDK feature flag\n * and feature experimentation management\n *\n * @returns {IUseFeatureFlag} an object containing the following methods:\n * - `isFeatureFlagActive`,\n * - `getFeatureFlagVariationKey`,\n * - `getFeatureFlagVariable`,\n * - `getVisitorFeatureFlags`,\n * - `getFeatureFlags`,\n * - `getFeatureFlagVariables`,\n * - `getEngineTrackingCode`\n */\nexport function useFeatureFlag(): IUseFeatureFlag {\n const client = useKameleoon();\n\n const isFeatureFlagActive = useCallback(\n (visitorCode: string, featureKey: string): boolean => {\n return client.isFeatureFlagActive(visitorCode, featureKey);\n },\n [client],\n );\n\n const getFeatureFlagVariationKey = useCallback(\n (visitorCode: string, featureKey: string): string => {\n return client.getFeatureFlagVariationKey(visitorCode, featureKey);\n },\n [client],\n );\n\n const getFeatureFlagVariable = useCallback(\n ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType): FeatureFlagVariableType => {\n return client.getFeatureFlagVariable({\n visitorCode,\n featureKey,\n variableKey,\n });\n },\n [client],\n );\n\n const getVisitorFeatureFlags = useCallback(\n (visitorCode: string): FeatureFlagType[] => {\n return client.getVisitorFeatureFlags(visitorCode);\n },\n [client],\n );\n\n const getFeatureFlags = useCallback((): FeatureFlagType[] => {\n return client.getFeatureFlags();\n }, [client]);\n\n const getFeatureFlagVariables = useCallback(\n (visitorCode, featureKey): FeatureVariableResultType[] => {\n return client.getFeatureFlagVariables(visitorCode, featureKey);\n },\n [client],\n );\n\n const getEngineTrackingCode = useCallback(\n (visitorCode: string): string => {\n return client.getEngineTrackingCode(visitorCode);\n },\n [client],\n );\n\n return {\n getFeatureFlags,\n isFeatureFlagActive,\n getEngineTrackingCode,\n getVisitorFeatureFlags,\n getFeatureFlagVariable,\n getFeatureFlagVariables,\n getFeatureFlagVariationKey,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFeatureFlag.js","names":["useFeatureFlag","client","useKameleoon","isFeatureFlagActive","useCallback","visitorCode","featureKey","getFeatureFlagVariationKey","getFeatureFlagVariable","b","variableKey","getVisitorFeatureFlags","getActiveFeatureFlags","getFeatureFlags","getFeatureFlagVariables","getEngineTrackingCode"],"sources":["../src/useFeatureFlag.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport IUseFeatureFlag from './interfaces/useFeatureFlag';\nimport { useKameleoon } from './useKameleoon';\nimport {\n FeatureFlagType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n KameleoonVariationType,\n GetFeatureFlagVariableParamsType,\n} from '@kameleoon/javascript-sdk';\n\n/**\n * A React Hook that returns methods related to SDK feature flag\n * and feature experimentation management\n *\n * @returns {IUseFeatureFlag} an object containing the following methods:\n * - `isFeatureFlagActive`,\n * - `getFeatureFlagVariationKey`,\n * - `getFeatureFlagVariable`,\n * - `getVisitorFeatureFlags`,\n * - `getActiveFeatureFlags`,\n * - `getFeatureFlags`,\n * - `getFeatureFlagVariables`,\n * - `getEngineTrackingCode`\n */\nexport function useFeatureFlag(): IUseFeatureFlag {\n const client = useKameleoon();\n\n const isFeatureFlagActive = useCallback(\n (visitorCode: string, featureKey: string): boolean => {\n return client.isFeatureFlagActive(visitorCode, featureKey);\n },\n [client],\n );\n\n const getFeatureFlagVariationKey = useCallback(\n (visitorCode: string, featureKey: string): string => {\n return client.getFeatureFlagVariationKey(visitorCode, featureKey);\n },\n [client],\n );\n\n const getFeatureFlagVariable = useCallback(\n ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType): FeatureFlagVariableType => {\n return client.getFeatureFlagVariable({\n visitorCode,\n featureKey,\n variableKey,\n });\n },\n [client],\n );\n\n const getVisitorFeatureFlags = useCallback(\n (visitorCode: string): FeatureFlagType[] => {\n return client.getVisitorFeatureFlags(visitorCode);\n },\n [client],\n );\n\n const getActiveFeatureFlags = useCallback(\n (visitorCode: string): Map<string, KameleoonVariationType> => {\n return client.getActiveFeatureFlags(visitorCode);\n },\n [client],\n );\n\n const getFeatureFlags = useCallback((): FeatureFlagType[] => {\n return client.getFeatureFlags();\n }, [client]);\n\n const getFeatureFlagVariables = useCallback(\n (visitorCode, featureKey): FeatureVariableResultType[] => {\n return client.getFeatureFlagVariables(visitorCode, featureKey);\n },\n [client],\n );\n\n const getEngineTrackingCode = useCallback(\n (visitorCode: string): string => {\n return client.getEngineTrackingCode(visitorCode);\n },\n [client],\n );\n\n return {\n getActiveFeatureFlags,\n getFeatureFlags,\n isFeatureFlagActive,\n getEngineTrackingCode,\n getVisitorFeatureFlags,\n getFeatureFlagVariable,\n getFeatureFlagVariables,\n getFeatureFlagVariationKey,\n };\n}\n"],"mappings":"8KAyBO,QAAS,CAAAA,cAAcA,CAAA,CAAoB,MAC1C,CAAAC,CAAM,CAAG,GAAAC,0BAAY,EAAC,CAAC,CAEvBC,CAAmB,CAAG,GAAAC,kBAAW,EACrC,CAACC,CAAmB,CAAEC,CAAkB,GAC/BL,CAAM,CAACE,mBAAmB,CAACE,CAAW,CAAEC,CAAU,CAC1D,CACD,CAACL,CAAM,CACT,CAAC,CAEKM,CAA0B,CAAG,GAAAH,kBAAW,EAC5C,CAACC,CAAmB,CAAEC,CAAkB,GAC/BL,CAAM,CAACM,0BAA0B,CAACF,CAAW,CAAEC,CAAU,CACjE,CACD,CAACL,CAAM,CACT,CAAC,CAEKO,CAAsB,CAAG,GAAAJ,kBAAW,EACxCK,CAAA,EAIiE,IAJhE,CACCJ,WAAW,CAAXA,CAAW,CACXC,UAAU,CAAVA,CAAU,CACVI,WAAW,CAAXA,CACgC,CAAC,CAAAD,CAAA,CACjC,MAAO,CAAAR,CAAM,CAACO,sBAAsB,CAAC,CACnCH,WAAW,CAAXA,CAAW,CACXC,UAAU,CAAVA,CAAU,CACVI,WAAW,CAAXA,CACF,CAAC,CACH,CAAC,CACD,CAACT,CAAM,CACT,CAAC,CAEKU,CAAsB,CAAG,GAAAP,kBAAW,EACvCC,CAAmB,EACXJ,CAAM,CAACU,sBAAsB,CAACN,CAAW,CACjD,CACD,CAACJ,CAAM,CACT,CAAC,CAEKW,CAAqB,CAAG,GAAAR,kBAAW,EACtCC,CAAmB,EACXJ,CAAM,CAACW,qBAAqB,CAACP,CAAW,CAChD,CACD,CAACJ,CAAM,CACT,CAAC,CAEKY,CAAe,CAAG,GAAAT,kBAAW,EAAC,IAC3BH,CAAM,CAACY,eAAe,CAAC,CAC/B,CAAE,CAACZ,CAAM,CAAC,CAAC,CAENa,CAAuB,CAAG,GAAAV,kBAAW,EACzC,CAACC,CAAW,CAAEC,CAAU,GACfL,CAAM,CAACa,uBAAuB,CAACT,CAAW,CAAEC,CAAU,CAC9D,CACD,CAACL,CAAM,CACT,CAAC,CAEKc,CAAqB,CAAG,GAAAX,kBAAW,EACtCC,CAAmB,EACXJ,CAAM,CAACc,qBAAqB,CAACV,CAAW,CAChD,CACD,CAACJ,CAAM,CACT,CAAC,CAED,MAAO,CACLW,qBAAqB,CAArBA,CAAqB,CACrBC,eAAe,CAAfA,CAAe,CACfV,mBAAmB,CAAnBA,CAAmB,CACnBY,qBAAqB,CAArBA,CAAqB,CACrBJ,sBAAsB,CAAtBA,CAAsB,CACtBH,sBAAsB,CAAtBA,CAAsB,CACtBM,uBAAuB,CAAvBA,CAAuB,CACvBP,0BAA0B,CAA1BA,CACF,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kameleoon/react-sdk",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "Kameleoon React SDK",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
],
|
|
37
37
|
"license": "ISC",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@kameleoon/javascript-sdk": "3.
|
|
39
|
+
"@kameleoon/javascript-sdk": "3.2.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|