@kameleoon/react-sdk 9.2.0 → 9.3.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,10 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.3.0 (2024-05-24)
4
+
5
+ ### Features
6
+
7
+ - Added new [`onEvent`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk/#onevent) method retuned from `useInitialize` hook to handle SDK events with a callback.
8
+ - Method [`onConfigurationUpdate`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk/#onConfigurationUpdate) is now marked as `deprecated` and will be removed in the next major release. Use [`onEvent(EventType.ConfigurationUpdate, callback)`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#onevent) instead.
9
+ - Added support of range match type for numeric Custom Data values.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+ - @kameleoon/javascript-sdk@3.3.0
15
+
3
16
  ## 9.2.0 (2024-05-07)
4
17
 
5
18
  ### Features
6
19
 
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.
20
+ - New method [`getActiveFeatureFlags`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk/#getactivefeatureflags) obtained with `useFeature` hook, which retrieves feature flags that are active for visitor with detailed variation and variables information.
8
21
 
9
22
  ### Patch Changes
10
23
 
@@ -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.2.0"}});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.3.0"}});return e}
2
2
  //# sourceMappingURL=createClient.js.map
@@ -3,6 +3,9 @@ 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.
5
5
  *
6
+ * Note: This method **sends** tracking data
7
+ * Triggered Events: `EventType.Evaluation`
8
+ *
6
9
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.
7
10
  * @param {string} featureKey - a unique key for feature flag.
8
11
  * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`.
@@ -19,6 +22,10 @@ export default interface IUseFeatureFlag {
19
22
  /**
20
23
  * 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.
21
24
  *
25
+ *
26
+ * Note: This method **sends** tracking data
27
+ * Triggered Events: `EventType.Evaluation`
28
+ *
22
29
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.
23
30
  * @param {string} featureKey - a unique key for feature flag.
24
31
  * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor.
@@ -34,6 +41,9 @@ export default interface IUseFeatureFlag {
34
41
  /**
35
42
  * 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.
36
43
  *
44
+ * Note: This method **sends** tracking data
45
+ * Triggered Events: `EventType.Evaluation`
46
+ *
37
47
  * @param {GetFeatureFlagVariableParamsType} params - `visitorCode`, `featureKey` and `variableKey` parameters to return variable.
38
48
  * @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.
39
49
  * @throws `KameleoonError` with one of the following `type` s:
@@ -51,6 +61,10 @@ export default interface IUseFeatureFlag {
51
61
  /**
52
62
  * 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).
53
63
  *
64
+ *
65
+ * Note: This method **doesn't send** tracking data
66
+ * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)
67
+ *
54
68
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.
55
69
  * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.
56
70
  * @throws `KameleoonError` with one of the following `type` s:
@@ -64,7 +78,10 @@ export default interface IUseFeatureFlag {
64
78
  /**
65
79
  * @method getActiveFeatureFlags - method collecting all active feature flags information including it's variation and variables for the visitor
66
80
  *
81
+ *
67
82
  * Note: This method **doesn't send** tracking data
83
+ * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)
84
+ *
68
85
  *
69
86
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
70
87
  * @returns {Map<string, KameleoonVariationType>} a map of feature flags with `featureKey` as a key and `KameleoonVariationType` as a value
@@ -84,12 +101,18 @@ export default interface IUseFeatureFlag {
84
101
  * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.
85
102
  * @throws `KameleoonError` with one of the following `type` s:
86
103
  *
104
+ * Note: This method **doesn't send** tracking data
105
+ *
87
106
  * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.
88
107
  */
89
108
  getFeatureFlags: () => FeatureFlagType[];
90
109
  /**
91
110
  * 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.
92
111
  *
112
+ *
113
+ * Note: This method **sends** tracking data
114
+ * Triggered Events: `EventType.Evaluation`
115
+ *
93
116
  * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters.
94
117
  * @param {string} featureKey - a unique key for feature flag.
95
118
  * @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.
@@ -1 +1 @@
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":""}
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 * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\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 *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\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 * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\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 *\n * Note: This method **doesn't send** tracking data\n * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)\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 *\n * Note: This method **doesn't send** tracking data\n * Triggered Events: `EventType.Evaluation` (For each feature flag evaluated)\n *\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 * Note: This method **doesn't send** tracking data\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 *\n * Note: This method **sends** tracking data\n * Triggered Events: `EventType.Evaluation`\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,3 +1,4 @@
1
+ import { EventCallbackType, EventType } from '@kameleoon/javascript-sdk';
1
2
  export default interface IUseInitialize {
2
3
  /**
3
4
  * 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.
@@ -12,6 +13,10 @@ export default interface IUseInitialize {
12
13
  */
13
14
  initialize: () => Promise<boolean>;
14
15
  /**
16
+ * @deprecated
17
+ * use `onEvent(EventType.ConfigurationUpdate, callback)` instead
18
+ * Will be removed in the next major release
19
+ *
15
20
  * Fires a callback on client configuration update. Note: this method only works for server sent events of real time update.
16
21
  *
17
22
  * @param {() => void} callback - callback function with no parameters that will be called upon configuration update.
@@ -20,6 +25,23 @@ export default interface IUseInitialize {
20
25
  * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.
21
26
  */
22
27
  onConfigurationUpdate: (callback: () => void) => void;
28
+ /**
29
+ * @method onEvent - fires a callback on a specified Kameleoon `EventType`. Each event can only have one according callback.
30
+ *
31
+ * Note: SDK methods are marked with the `EventType` they trigger if any.
32
+ *
33
+ * @param {EventCallbackType<EventType>} callback - callback function with parameters that will be called upon event
34
+ *
35
+ * Parameter type depends on the `EventType` passed:
36
+ * - `EventType.Evaluation` - `EvaluationEventDataType`
37
+ * - `EventType.ConfigurationUpdate` - `ConfigurationUpdateEventDataType`
38
+ *
39
+ * @returns {void}
40
+ * @throws `KameleoonError` with one of the following `type` s:
41
+ *
42
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
43
+ */
44
+ onEvent: (event: EventType, callback: EventCallbackType<EventType>) => void;
23
45
  /**
24
46
  * Checks if client is initialized.
25
47
  *
@@ -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 * Checks if client is initialized.\n *\n * @returns {boolean} - `true` if client is initialized, `false` otherwise.\n */\n isInitialized: () => boolean;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"useInitialize.js","names":[],"sources":["../../src/interfaces/useInitialize.ts"],"sourcesContent":["import { EventCallbackType, EventType } from '@kameleoon/javascript-sdk';\n\nexport 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 * @deprecated\n * use `onEvent(EventType.ConfigurationUpdate, callback)` instead\n * Will be removed in the next major release\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 * @method onEvent - fires a callback on a specified Kameleoon `EventType`. Each event can only have one according callback.\n *\n * Note: SDK methods are marked with the `EventType` they trigger if any.\n *\n * @param {EventCallbackType<EventType>} callback - callback function with parameters that will be called upon event\n *\n * Parameter type depends on the `EventType` passed:\n * - `EventType.Evaluation` - `EvaluationEventDataType`\n * - `EventType.ConfigurationUpdate` - `ConfigurationUpdateEventDataType`\n *\n * @returns {void}\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 onEvent: (event: EventType, callback: EventCallbackType<EventType>) => 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":""}
@@ -5,6 +5,7 @@ import IUseInitialize from './interfaces/useInitialize';
5
5
  * @returns {IUseInitialize} an object containing the following methods:
6
6
  * - `initialize`
7
7
  * - `isInitialized`
8
+ * - `onEvent`
8
9
  * - `onConfigurationUpdate`
9
10
  */
10
11
  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]),d=(0,_react.useCallback)(()=>a.isInitialized(),[a]);return{initialize:b,isInitialized:d,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)((b,c)=>{a.onEvent(b,c)},[a]),e=(0,_react.useCallback)(()=>a.isInitialized(),[a]);return{onEvent:d,initialize:b,isInitialized:e,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","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"}
1
+ {"version":3,"file":"useInitialize.js","names":["useInitialize","client","useKameleoon","initialize","useCallback","useCache","onConfigurationUpdate","callback","onEvent","event","isInitialized"],"sources":["../src/useInitialize.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\nimport IUseInitialize from './interfaces/useInitialize';\nimport { EventCallbackType, EventType } from '@kameleoon/javascript-sdk';\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 * - `onEvent`\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 onEvent = useCallback(\n <E extends EventType>(event: E, callback: EventCallbackType<E>): void => {\n client.onEvent(event, callback);\n },\n [client],\n );\n\n const isInitialized = useCallback((): boolean => {\n return client.isInitialized();\n }, [client]);\n\n return {\n onEvent,\n initialize,\n isInitialized,\n onConfigurationUpdate,\n };\n}\n"],"mappings":"4KAcO,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,CAAO,CAAG,GAAAJ,kBAAW,EACzB,CAAsBK,CAAQ,CAAEF,CAA8B,GAAW,CACvEN,CAAM,CAACO,OAAO,CAACC,CAAK,CAAEF,CAAQ,CAChC,CAAC,CACD,CAACN,CAAM,CACT,CAAC,CAEKS,CAAa,CAAG,GAAAN,kBAAW,EAAC,IACzBH,CAAM,CAACS,aAAa,CAAC,CAC7B,CAAE,CAACT,CAAM,CAAC,CAAC,CAEZ,MAAO,CACLO,OAAO,CAAPA,CAAO,CACPL,UAAU,CAAVA,CAAU,CACVO,aAAa,CAAbA,CAAa,CACbJ,qBAAqB,CAArBA,CACF,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/react-sdk",
3
- "version": "9.2.0",
3
+ "version": "9.3.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.2.0"
39
+ "@kameleoon/javascript-sdk": "3.3.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"