@kameleoon/react-sdk 9.3.0 → 9.4.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,22 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.4.0 (2024-06-21)
4
+
5
+ ### Features
6
+
7
+ - Added new [`networkDomain`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#1-create-kameleoon-client) parameter in `SDKConfigurationType` for configuring custom network domain for all outgoing requests.
8
+ - [`SDKConfigurationType`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#1-create-kameleoon-client) parameter `domain` was deprecated and will be removed in the next major version. Instead new `cookieDomain` is available.
9
+ - Consent value can now be read automatically from the JS Script if the visitor code is set in cookie.
10
+ - Add new optional [External Dependency](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#external-dependencies) - [Requester](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#requester) for implementing custom network request handler
11
+ - Added new `KameleoonUtils` methods:
12
+ - [`getCookieValue`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#getcookievalue) for extracting cookie value from cookie string
13
+ - [`simulateSuccessRequest`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/react-js-sdk#simulatesuccessrequest) for mocking successful network requests when implementing custom `Requester`
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+ - @kameleoon/javascript-sdk@3.4.0
19
+
3
20
  ## 9.3.0 (2024-05-24)
4
21
 
5
22
  ### Features
@@ -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.3.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.4.0"}});return e}
2
2
  //# sourceMappingURL=createClient.js.map
@@ -41,7 +41,7 @@ export default interface IUseInitialize {
41
41
  *
42
42
  * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
43
43
  */
44
- onEvent: (event: EventType, callback: EventCallbackType<EventType>) => void;
44
+ onEvent: <E extends EventType>(event: E, callback: EventCallbackType<E>) => void;
45
45
  /**
46
46
  * Checks if client is initialized.
47
47
  *
@@ -1 +1 @@
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":""}
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: <E extends EventType>(\n event: E,\n callback: EventCallbackType<E>,\n ) => 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":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/react-sdk",
3
- "version": "9.3.0",
3
+ "version": "9.4.0",
4
4
  "description": "Kameleoon React SDK",
5
5
  "files": [
6
6
  "dist"
@@ -9,7 +9,7 @@
9
9
  "types": "dist/index.d.ts",
10
10
  "scripts": {
11
11
  "clean": "rimraf dist && rimraf tsconfig.tsbuildinfo",
12
- "start": "npm run clean && tsc -w",
12
+ "dev": "npm run clean && tsc -w -p tsconfig.watch.json",
13
13
  "build": "npm run clean && npm run build:types && npm run build:js",
14
14
  "build:types": "tsc --emitDeclarationOnly",
15
15
  "build:js": "babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps true",
@@ -36,7 +36,7 @@
36
36
  ],
37
37
  "license": "ISC",
38
38
  "dependencies": {
39
- "@kameleoon/javascript-sdk": "3.3.0"
39
+ "@kameleoon/javascript-sdk": "3.4.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"