@kameleoon/react-sdk 9.0.1 → 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 CHANGED
@@ -1,5 +1,36 @@
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
+
14
+ ## 9.1.0 (2024-04-19)
15
+
16
+ ### Features
17
+
18
+ - New [Likelihood to Convert](https://developers.kameleoon.com/feature-management-and-experimentation/using-visit-history-in-feature-flags-and-experiments/#predefined-targeting-conditions) targeting condition.
19
+ - Added [`isInitialized`](#https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#isinitialized) method obtained from `useInitialize` hook for checking if the SDK is initialized
20
+ - [`getRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#getremotevisitordata) method now accepts new boolean parameter `isUniqueIdentifier` to obtain all linked visitors data when working with [Cross-device experimentation](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#cross-device-experimentation)
21
+ - Miscellaneous [Cross-device experimentation](https://developers.kameleoon.com/core-concepts/cross-device-experimentation) improvements
22
+
23
+ ### Patch Changes
24
+
25
+ - Improved visits data collection logic
26
+ - Fixed the issue with when `_` variable was transformed to duplicate identifier `a` causing `TypeError`
27
+ - Kameleoon network request headers are now properly used
28
+ - `Browser` condition could throw an error when the browser version wasn't specified on Kameleoon Platform
29
+ - `Geolocation` condition is now case insensitive
30
+ - SDK Core version is no more sent with tracking
31
+ - Updated dependencies
32
+ - @kameleoon/javascript-sdk@3.1.0
33
+
3
34
  ## 9.0.1 (2024-02-21)
4
35
 
5
36
  ### Patch Changes
@@ -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.0.1"}});return e}
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
@@ -51,7 +51,7 @@ export default interface IUseData {
51
51
  /**
52
52
  * An asynchronous method for retrieving custom data for the latest visit of `visitorCode` from Kameleoon Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.
53
53
  *
54
- * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters
54
+ * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData`, `filters` and `isUniqueIdentifier` parameters
55
55
  * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances
56
56
  * @throws `KameleoonError` with one of the following `type` s:
57
57
  *
@@ -61,7 +61,7 @@ export default interface IUseData {
61
61
  * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25
62
62
  * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
63
63
  */
64
- getRemoteVisitorData: ({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;
64
+ getRemoteVisitorData: ({ visitorCode, shouldAddData, filters, isUniqueIdentifier, }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;
65
65
  /**
66
66
  * An asynchronous method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences
67
67
  * which is stored for specified visitorCode on a remote Kameleoon server
@@ -1 +1 @@
1
- {"version":3,"file":"useData.js","names":[],"sources":["../../src/interfaces/useData.ts"],"sourcesContent":["import {\n CustomData,\n GetVisitorWarehouseAudienceParamsType,\n JSONType,\n KameleoonDataType,\n RemoteVisitorDataParamsType,\n TrackConversionParamsType,\n} from '@kameleoon/javascript-sdk';\n\nexport default interface IUseData {\n /**\n * Adds targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: `UserAgent` data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @param {KameleoonDataType[]} data - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments.\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.StorageWrite` Couldn't update storage data.\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * Takes visitor associated kameleoon data and sends the data tracking request with collected data sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks.\n * If no visitor is passed, then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * execution starts with sending all previously failed tracking requests which were stored locally during the offline mode and then proceeds further.\n *\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\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 */\n flush: (visitorCode?: string, isUniqueIdentifier?: boolean) => void;\n /**\n * Creates and adds `Conversion` data to the visitor with specified parameters and executes `flushData`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter.\n *\n * @param {TrackConversionParamsType} params - `visitorCode`, `goalId`, `revenue` and `isUniqueIdentifier` parameters for data tracking.\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.StorageWrite` Couldn't update storage data.\n */\n trackConversion: (params: TrackConversionParamsType) => void;\n /**\n * Returns a data which is stored for specified siteCode on a remote Kameleoon server.\n *\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {Promise<JSONType>} promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server.\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n /**\n * An asynchronous method for retrieving custom data for the latest visit of `visitorCode` from Kameleoon Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n *\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances\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.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n /**\n * An asynchronous method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences\n * which is stored for specified visitorCode on a remote Kameleoon server\n * Retrieved data will be added to storage under the specified `customDataIndex`\n *\n * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details\n *\n * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`\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.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getVisitorWarehouseAudience: ({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"useData.js","names":[],"sources":["../../src/interfaces/useData.ts"],"sourcesContent":["import {\n CustomData,\n GetVisitorWarehouseAudienceParamsType,\n JSONType,\n KameleoonDataType,\n RemoteVisitorDataParamsType,\n TrackConversionParamsType,\n} from '@kameleoon/javascript-sdk';\n\nexport default interface IUseData {\n /**\n * Adds targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: `UserAgent` data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @param {KameleoonDataType[]} data - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments.\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.StorageWrite` Couldn't update storage data.\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * Takes visitor associated kameleoon data and sends the data tracking request with collected data sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks.\n * If no visitor is passed, then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * execution starts with sending all previously failed tracking requests which were stored locally during the offline mode and then proceeds further.\n *\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\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 */\n flush: (visitorCode?: string, isUniqueIdentifier?: boolean) => void;\n /**\n * Creates and adds `Conversion` data to the visitor with specified parameters and executes `flushData`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter.\n *\n * @param {TrackConversionParamsType} params - `visitorCode`, `goalId`, `revenue` and `isUniqueIdentifier` parameters for data tracking.\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.StorageWrite` Couldn't update storage data.\n */\n trackConversion: (params: TrackConversionParamsType) => void;\n /**\n * Returns a data which is stored for specified siteCode on a remote Kameleoon server.\n *\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {Promise<JSONType>} promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server.\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n /**\n * An asynchronous method for retrieving custom data for the latest visit of `visitorCode` from Kameleoon Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n *\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData`, `filters` and `isUniqueIdentifier` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances\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.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n isUniqueIdentifier,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n /**\n * An asynchronous method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences\n * which is stored for specified visitorCode on a remote Kameleoon server\n * Retrieved data will be added to storage under the specified `customDataIndex`\n *\n * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details\n *\n * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`\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.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getVisitorWarehouseAudience: ({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;\n}\n"],"mappings":""}
@@ -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":""}
@@ -20,4 +20,10 @@ export default interface IUseInitialize {
20
20
  * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.
21
21
  */
22
22
  onConfigurationUpdate: (callback: () => void) => void;
23
+ /**
24
+ * Checks if client is initialized.
25
+ *
26
+ * @returns {boolean} - `true` if client is initialized, `false` otherwise.
27
+ */
28
+ isInitialized: () => boolean;
23
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useInitialize.js","names":[],"sources":["../../src/interfaces/useInitialize.ts"],"sourcesContent":["export default interface IUseInitialize {\n /**\n * An asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached.\n *\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data.\n * - `KameleoonException.StorageRead` - Couldn't read storage data.\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api.\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize: () => Promise<boolean>;\n /**\n * Fires a callback on client configuration update. Note: this method only works for server sent events of real time update.\n *\n * @param {() => void} callback - callback function with no parameters that will be called upon configuration update.\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 onConfigurationUpdate: (callback: () => void) => void;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"useInitialize.js","names":[],"sources":["../../src/interfaces/useInitialize.ts"],"sourcesContent":["export default interface IUseInitialize {\n /**\n * An asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached.\n *\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data.\n * - `KameleoonException.StorageRead` - Couldn't read storage data.\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api.\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize: () => Promise<boolean>;\n /**\n * Fires a callback on client configuration update. Note: this method only works for server sent events of real time update.\n *\n * @param {() => void} callback - callback function with no parameters that will be called upon configuration update.\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 onConfigurationUpdate: (callback: () => void) => void;\n /**\n * Checks if client is initialized.\n *\n * @returns {boolean} - `true` if client is initialized, `false` otherwise.\n */\n isInitialized: () => boolean;\n}\n"],"mappings":""}
@@ -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`
@@ -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]),g=(0,_react.useCallback)((b,c)=>a.getFeatureFlagVariables(b,c),[a]),h=(0,_react.useCallback)(b=>a.getEngineTrackingCode(b),[a]);return{getFeatureFlags:f,isFeatureFlagActive:b,getEngineTrackingCode:h,getVisitorFeatureFlags:e,getFeatureFlagVariable:d,getFeatureFlagVariables:g,getFeatureFlagVariationKey:c}}
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":"8KAuBO,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,CAAe,CAAG,GAAAR,kBAAW,EAAC,IAC3BH,CAAM,CAACW,eAAe,CAAC,CAC/B,CAAE,CAACX,CAAM,CAAC,CAAC,CAENY,CAAuB,CAAG,GAAAT,kBAAW,EACzC,CAACC,CAAW,CAAEC,CAAU,GACfL,CAAM,CAACY,uBAAuB,CAACR,CAAW,CAAEC,CAAU,CAC9D,CACD,CAACL,CAAM,CACT,CAAC,CAEKa,CAAqB,CAAG,GAAAV,kBAAW,EACtCC,CAAmB,EACXJ,CAAM,CAACa,qBAAqB,CAACT,CAAW,CAChD,CACD,CAACJ,CAAM,CACT,CAAC,CAED,MAAO,CACLW,eAAe,CAAfA,CAAe,CACfT,mBAAmB,CAAnBA,CAAmB,CACnBW,qBAAqB,CAArBA,CAAqB,CACrBH,sBAAsB,CAAtBA,CAAsB,CACtBH,sBAAsB,CAAtBA,CAAsB,CACtBK,uBAAuB,CAAvBA,CAAuB,CACvBN,0BAA0B,CAA1BA,CACF,CACF"}
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"}
@@ -4,6 +4,7 @@ import IUseInitialize from './interfaces/useInitialize';
4
4
  *
5
5
  * @returns {IUseInitialize} an object containing the following methods:
6
6
  * - `initialize`
7
+ * - `isInitialized`
7
8
  * - `onConfigurationUpdate`
8
9
  */
9
10
  export declare function useInitialize(): IUseInitialize;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useInitialize=useInitialize;var _react=require("react"),_useKameleoon=require("./useKameleoon");function useInitialize(){const a=(0,_useKameleoon.useKameleoon)(),b=(0,_react.useCallback)(async b=>await a.initialize(b),[a]),c=(0,_react.useCallback)(b=>{a.onConfigurationUpdate(b)},[a]);return{initialize:b,onConfigurationUpdate:c}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useInitialize=useInitialize;var _react=require("react"),_useKameleoon=require("./useKameleoon");function useInitialize(){const a=(0,_useKameleoon.useKameleoon)(),b=(0,_react.useCallback)(async b=>await a.initialize(b),[a]),c=(0,_react.useCallback)(b=>{a.onConfigurationUpdate(b)},[a]),d=(0,_react.useCallback)(()=>a.isInitialized(),[a]);return{initialize:b,isInitialized:d,onConfigurationUpdate:c}}
2
2
  //# sourceMappingURL=useInitialize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInitialize.js","names":["useInitialize","client","useKameleoon","initialize","useCallback","useCache","onConfigurationUpdate","callback"],"sources":["../src/useInitialize.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\nimport IUseInitialize from './interfaces/useInitialize';\n\n/**\n * A React Hook that returns methods related to SDK setup and configuration\n *\n * @returns {IUseInitialize} an object containing the following methods:\n * - `initialize`\n * - `onConfigurationUpdate`\n */\nexport function useInitialize(): IUseInitialize {\n const client = useKameleoon();\n\n const initialize = useCallback(\n async (useCache?: boolean): Promise<boolean> => {\n return await client.initialize(useCache);\n },\n [client],\n );\n\n const onConfigurationUpdate = useCallback(\n (callback: () => void): void => {\n client.onConfigurationUpdate(callback);\n },\n [client],\n );\n\n return {\n initialize,\n onConfigurationUpdate,\n };\n}\n"],"mappings":"4KAWO,QAAS,CAAAA,aAAaA,CAAA,CAAmB,MACxC,CAAAC,CAAM,CAAG,GAAAC,0BAAY,EAAC,CAAC,CAEvBC,CAAU,CAAG,GAAAC,kBAAW,EAC5B,KAAO,CAAAC,CAAkB,EAChB,KAAM,CAAAJ,CAAM,CAACE,UAAU,CAACE,CAAQ,CACxC,CACD,CAACJ,CAAM,CACT,CAAC,CAEKK,CAAqB,CAAG,GAAAF,kBAAW,EACtCG,CAAoB,EAAW,CAC9BN,CAAM,CAACK,qBAAqB,CAACC,CAAQ,CACvC,CAAC,CACD,CAACN,CAAM,CACT,CAAC,CAED,MAAO,CACLE,UAAU,CAAVA,CAAU,CACVG,qBAAqB,CAArBA,CACF,CACF"}
1
+ {"version":3,"file":"useInitialize.js","names":["useInitialize","client","useKameleoon","initialize","useCallback","useCache","onConfigurationUpdate","callback","isInitialized"],"sources":["../src/useInitialize.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\nimport IUseInitialize from './interfaces/useInitialize';\n\n/**\n * A React Hook that returns methods related to SDK setup and configuration\n *\n * @returns {IUseInitialize} an object containing the following methods:\n * - `initialize`\n * - `isInitialized`\n * - `onConfigurationUpdate`\n */\nexport function useInitialize(): IUseInitialize {\n const client = useKameleoon();\n\n const initialize = useCallback(\n async (useCache?: boolean): Promise<boolean> => {\n return await client.initialize(useCache);\n },\n [client],\n );\n\n const onConfigurationUpdate = useCallback(\n (callback: () => void): void => {\n client.onConfigurationUpdate(callback);\n },\n [client],\n );\n\n const isInitialized = useCallback((): boolean => {\n return client.isInitialized();\n }, [client]);\n\n return {\n initialize,\n isInitialized,\n onConfigurationUpdate,\n };\n}\n"],"mappings":"4KAYO,QAAS,CAAAA,aAAaA,CAAA,CAAmB,MACxC,CAAAC,CAAM,CAAG,GAAAC,0BAAY,EAAC,CAAC,CAEvBC,CAAU,CAAG,GAAAC,kBAAW,EAC5B,KAAO,CAAAC,CAAkB,EAChB,KAAM,CAAAJ,CAAM,CAACE,UAAU,CAACE,CAAQ,CACxC,CACD,CAACJ,CAAM,CACT,CAAC,CAEKK,CAAqB,CAAG,GAAAF,kBAAW,EACtCG,CAAoB,EAAW,CAC9BN,CAAM,CAACK,qBAAqB,CAACC,CAAQ,CACvC,CAAC,CACD,CAACN,CAAM,CACT,CAAC,CAEKO,CAAa,CAAG,GAAAJ,kBAAW,EAAC,IACzBH,CAAM,CAACO,aAAa,CAAC,CAC7B,CAAE,CAACP,CAAM,CAAC,CAAC,CAEZ,MAAO,CACLE,UAAU,CAAVA,CAAU,CACVK,aAAa,CAAbA,CAAa,CACbF,qBAAqB,CAArBA,CACF,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/react-sdk",
3
- "version": "9.0.1",
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.0.1"
39
+ "@kameleoon/javascript-sdk": "3.2.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"