@kameleoon/react-sdk 10.1.3 → 10.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,6 +1,23 @@
1
1
  # Change Log
2
2
 
3
- ## 10.1.3
3
+ ## 10.2.0 (2024-12-09)
4
+
5
+ ### Features
6
+
7
+ - Added support for **simulated** variations.
8
+ - Added the [`setForcedVariation()`][setForcedVariation] method. This method allows explicitly setting a forced variation for a visitor, which will be applied during experiment evaluation.
9
+
10
+ ### Patch Changes
11
+
12
+ - Resolved an issue where the validation of [cookie domains][cookieDomain] for `localhost` resulted in incorrect failures. The SDK now accepts the provided domain without modification if it is deemed invalid and logs an [error][logLevels] to notify you of any issues with the specified domain.
13
+ - Updated dependencies
14
+ - @kameleoon/javascript-sdk@4.2.0
15
+
16
+ [setForcedVariation]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#setforcedvariation
17
+ [cookieDomain]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#configuration-parameters
18
+ [logLevels]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#log-levels
19
+
20
+ ## 10.1.3 (2024-12-06)
4
21
 
5
22
  ### Patch Changes
6
23
 
@@ -1 +1 @@
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:{packageInfo:{type:_javascriptSdk.SdkLanguageType.REACT,version:"10.1.3"},prng:null===d||void 0===d?void 0:d.prng}});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:{packageInfo:{type:_javascriptSdk.SdkLanguageType.REACT,version:"10.2.0"},prng:null===d||void 0===d?void 0:d.prng}});return e}
@@ -1,4 +1,4 @@
1
- import { FeatureFlagType, KameleoonVariationType, FeatureFlagVariableType, FeatureVariableResultType, GetFeatureFlagVariableParamsType, GetVariationsParamsType, VariationType, GetVariationParamsType, IsFeatureFlagActiveParamsType } from '@kameleoon/javascript-sdk';
1
+ import { FeatureFlagType, KameleoonVariationType, FeatureFlagVariableType, FeatureVariableResultType, GetFeatureFlagVariableParamsType, GetVariationsParamsType, VariationType, GetVariationParamsType, IsFeatureFlagActiveParamsType, SetForcedVariationParametersType } from '@kameleoon/javascript-sdk';
2
2
  export default interface IUseFeatureFlag {
3
3
  /**
4
4
  * Returns a variation for the visitor under `visitorCode` for the specified `featureKye`, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage
@@ -198,4 +198,22 @@ export default interface IUseFeatureFlag {
198
198
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
199
199
  */
200
200
  getEngineTrackingCode: (visitorCode: string) => string;
201
+ /**
202
+ * @method setForcedVariation - Sets or resets a forced variation for a visitor in a specific experiment, so the experiment will
203
+ * be evaluated to the variation for the visitor.
204
+ * In order to reset the forced variation, set the `variationKey` parameter to `null`. If the forced
205
+ * variation you want to reset does not exist, the method will have no effect.
206
+ *
207
+ * @param {SetForcedVariationParametersType} parameters an object with parameters of a type `SetForcedVariationParametersType`, see the type for details.
208
+ * @returns {void}
209
+ * @throws `KameleoonError` with one of the following `type` s:
210
+ * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
211
+ * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
212
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
213
+ * - `KameleoonException.FeatureFlagExperimentNotFound` - The experiment id does not exist in the feature flag.
214
+ * - `KameleoonException.FeatureFlagVariationNotFound` - The variation key does not belong to the experiment.
215
+ * - `KameleoonException.StorageRead` - Couldn't read storage data
216
+ * - `KameleoonException.StorageWrite` - Couldn't update storage data
217
+ */
218
+ setForcedVariation: ({ visitorCode, experimentId, variationKey, forceTargeting, }: SetForcedVariationParametersType) => void;
201
219
  }
@@ -13,6 +13,7 @@ import IUseFeatureFlag from './interfaces/useFeatureFlag';
13
13
  * - `getActiveFeatureFlags`,
14
14
  * - `getFeatureFlags`,
15
15
  * - `getFeatureFlagVariables`,
16
- * - `getEngineTrackingCode`
16
+ * - `getEngineTrackingCode`,
17
+ * - `setForcedVariation`
17
18
  */
18
19
  export declare function useFeatureFlag(): IUseFeatureFlag;
@@ -1 +1 @@
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)=>{if("string"==typeof b){if(!c)throw new Error("[Kameleoon React SDK Error]: Overload is not used correctly. The second parameter must be provided when the first parameter is a string");return a.isFeatureFlagActive(b,c)}return a.isFeatureFlagActive(b)},[a]),c=(0,_react.useCallback)(b=>{let{visitorCode:c,featureKey:d,track:e}=b;return a.getVariation({visitorCode:c,featureKey:d,track:e})},[a]),d=(0,_react.useCallback)(b=>{let{visitorCode:c,onlyActive:d,track:e}=b;return a.getVariations({visitorCode:c,onlyActive:d,track:e})},[a]),e=(0,_react.useCallback)((b,c)=>a.getFeatureFlagVariationKey(b,c),[a]),f=(0,_react.useCallback)(b=>{let{visitorCode:c,featureKey:d,variableKey:e}=b;return a.getFeatureFlagVariable({visitorCode:c,featureKey:d,variableKey:e})},[a]),g=(0,_react.useCallback)(b=>a.getVisitorFeatureFlags(b),[a]),h=(0,_react.useCallback)(b=>a.getActiveFeatureFlags(b),[a]),i=(0,_react.useCallback)(()=>a.getFeatureFlags(),[a]),j=(0,_react.useCallback)((b,c)=>a.getFeatureFlagVariables(b,c),[a]),k=(0,_react.useCallback)(b=>a.getEngineTrackingCode(b),[a]);return{getActiveFeatureFlags:h,getVariation:c,getVariations:d,getFeatureFlags:i,isFeatureFlagActive:b,getEngineTrackingCode:k,getVisitorFeatureFlags:g,getFeatureFlagVariable:f,getFeatureFlagVariables:j,getFeatureFlagVariationKey:e}}
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)=>{if("string"==typeof b){if(!c)throw new Error("[Kameleoon React SDK Error]: Overload is not used correctly. The second parameter must be provided when the first parameter is a string");return a.isFeatureFlagActive(b,c)}return a.isFeatureFlagActive(b)},[a]),c=(0,_react.useCallback)(b=>{let{visitorCode:c,featureKey:d,track:e}=b;return a.getVariation({visitorCode:c,featureKey:d,track:e})},[a]),d=(0,_react.useCallback)(b=>{let{visitorCode:c,onlyActive:d,track:e}=b;return a.getVariations({visitorCode:c,onlyActive:d,track:e})},[a]),e=(0,_react.useCallback)((b,c)=>a.getFeatureFlagVariationKey(b,c),[a]),f=(0,_react.useCallback)(b=>{let{visitorCode:c,featureKey:d,variableKey:e}=b;return a.getFeatureFlagVariable({visitorCode:c,featureKey:d,variableKey:e})},[a]),g=(0,_react.useCallback)(b=>a.getVisitorFeatureFlags(b),[a]),h=(0,_react.useCallback)(b=>a.getActiveFeatureFlags(b),[a]),i=(0,_react.useCallback)(()=>a.getFeatureFlags(),[a]),j=(0,_react.useCallback)((b,c)=>a.getFeatureFlagVariables(b,c),[a]),k=(0,_react.useCallback)(b=>a.getEngineTrackingCode(b),[a]),l=(0,_react.useCallback)(b=>{let{visitorCode:c,experimentId:d,variationKey:e,forceTargeting:f}=b;return a.setForcedVariation({visitorCode:c,experimentId:d,variationKey:e,forceTargeting:f})},[a]);return{getActiveFeatureFlags:h,getVariation:c,getVariations:d,getFeatureFlags:i,isFeatureFlagActive:b,getEngineTrackingCode:k,getVisitorFeatureFlags:g,getFeatureFlagVariable:f,getFeatureFlagVariables:j,getFeatureFlagVariationKey:e,setForcedVariation:l}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/react-sdk",
3
- "version": "10.1.3",
3
+ "version": "10.2.0",
4
4
  "description": "Kameleoon React SDK",
5
5
  "files": [
6
6
  "dist"
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "license": "ISC",
40
40
  "dependencies": {
41
- "@kameleoon/javascript-sdk": "4.1.3"
41
+ "@kameleoon/javascript-sdk": "4.2.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"