@kameleoon/react-sdk 9.0.0 → 9.1.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,32 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.1.0 (2024-04-19)
4
+
5
+ ### Features
6
+
7
+ - 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.
8
+ - 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
9
+ - [`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)
10
+ - Miscellaneous [Cross-device experimentation](https://developers.kameleoon.com/core-concepts/cross-device-experimentation) improvements
11
+
12
+ ### Patch Changes
13
+
14
+ - Improved visits data collection logic
15
+ - Fixed the issue with when `_` variable was transformed to duplicate identifier `a` causing `TypeError`
16
+ - Kameleoon network request headers are now properly used
17
+ - `Browser` condition could throw an error when the browser version wasn't specified on Kameleoon Platform
18
+ - `Geolocation` condition is now case insensitive
19
+ - SDK Core version is no more sent with tracking
20
+ - Updated dependencies
21
+ - @kameleoon/javascript-sdk@3.1.0
22
+
23
+ ## 9.0.1 (2024-02-21)
24
+
25
+ ### Patch Changes
26
+
27
+ - `<KameleoonProvider />` React dependency is now properly used
28
+ - Convert dependency on [JavaScript SDK](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/) from peer to concrete
29
+
3
30
  ## 9.0.0 (2024-02-16)
4
31
 
5
32
  ### Breaking Changes
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { KameleoonClient } from '@kameleoon/javascript-sdk';
3
- export declare const KameleoonContext: import("react").Context<KameleoonClient | null>;
3
+ export declare const KameleoonContext: React.Context<KameleoonClient | null>;
@@ -1,2 +1,2 @@
1
- "use strict";var _react=require("react");Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonContext=void 0;const KameleoonContext=exports.KameleoonContext=(0,_react.createContext)(null);
1
+ "use strict";var _react=_interopRequireDefault(require("react"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonContext=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}const KameleoonContext=exports.KameleoonContext=_react.default.createContext(null);
2
2
  //# sourceMappingURL=KameleoonContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KameleoonContext.js","names":["_react","require","Object","defineProperty","exports","value","KameleoonContext","createContext"],"sources":["../src/KameleoonContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { KameleoonClient } from '@kameleoon/javascript-sdk';\n\nexport const KameleoonContext = createContext<KameleoonClient | null>(null);\n"],"mappings":"aAAA,IAAAA,MAAA,CAAAC,OAAA,UAAsCC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,gBAAA,QAG/B,KAAM,CAAAA,gBAAgB,CAAAF,OAAA,CAAAE,gBAAA,CAAG,GAAAC,oBAAa,EAAyB,IAAI,CAAC"}
1
+ {"version":3,"file":"KameleoonContext.js","names":["_react","_interopRequireDefault","require","Object","defineProperty","exports","value","KameleoonContext","a","__esModule","default","React","createContext"],"sources":["../src/KameleoonContext.ts"],"sourcesContent":["import React from 'react';\nimport { KameleoonClient } from '@kameleoon/javascript-sdk';\n\nexport const KameleoonContext = React.createContext<KameleoonClient | null>(\n null,\n);\n"],"mappings":"aAAA,IAAAA,MAAA,CAAAC,sBAAA,CAAAC,OAAA,WAA0BC,MAAA,CAAAC,cAAA,CAAAC,OAAA,eAAAC,KAAA,MAAAD,OAAA,CAAAE,gBAAA,iBAAAN,uBAAAO,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,EAAAE,OAAA,CAAAF,CAAA,EAGnB,KAAM,CAAAD,gBAAgB,CAAAF,OAAA,CAAAE,gBAAA,CAAGI,cAAK,CAACC,aAAa,CACjD,IACF,CAAC"}
@@ -1,14 +1,14 @@
1
- import { ReactNode } from 'react';
1
+ import React from 'react';
2
2
  import { KameleoonClient } from '@kameleoon/javascript-sdk';
3
3
  export interface IKameleoonProviderProps {
4
4
  /** Child elements of the provider. */
5
- children: ReactNode;
5
+ children: React.ReactNode;
6
6
  /** An instance of Kameleoon SDK. */
7
7
  client: KameleoonClient;
8
8
  }
9
9
  /**
10
10
  * A Provider that wraps the project and provides an access to SDK APIs
11
11
  */
12
- declare function KameleoonProvider({ client, children, }: IKameleoonProviderProps): JSX.Element;
13
- declare const _default: import("react").MemoExoticComponent<typeof KameleoonProvider>;
12
+ declare function KameleoonProvider({ client, children, }: IKameleoonProviderProps): React.JSX.Element;
13
+ declare const _default: React.MemoExoticComponent<typeof KameleoonProvider>;
14
14
  export default _default;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _react=require("react"),_KameleoonContext=require("./KameleoonContext");function KameleoonProvider(a){let{client:b,children:c}=a;return React.createElement(_KameleoonContext.KameleoonContext.Provider,{value:b},c)}var _default=exports.default=(0,_react.memo)(KameleoonProvider);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _react=_interopRequireDefault(require("react")),_KameleoonContext=require("./KameleoonContext");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function KameleoonProvider(a){let{client:b,children:c}=a;return _react.default.createElement(_KameleoonContext.KameleoonContext.Provider,{value:b},c)}var _default=exports.default=_react.default.memo(KameleoonProvider);
2
2
  //# sourceMappingURL=KameleoonProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KameleoonProvider.js","names":["KameleoonProvider","a","client","children","React","createElement","_KameleoonContext","KameleoonContext","Provider","value","_default","exports","default","memo"],"sources":["../src/KameleoonProvider.tsx"],"sourcesContent":["import { memo, ReactNode } from 'react';\nimport { KameleoonClient } from '@kameleoon/javascript-sdk';\nimport { KameleoonContext } from './KameleoonContext';\n\nexport interface IKameleoonProviderProps {\n /** Child elements of the provider. */\n children: ReactNode;\n /** An instance of Kameleoon SDK. */\n client: KameleoonClient;\n}\n\n/**\n * A Provider that wraps the project and provides an access to SDK APIs\n */\nfunction KameleoonProvider({\n client,\n children,\n}: IKameleoonProviderProps): JSX.Element {\n return (\n <KameleoonContext.Provider value={client}>\n {children}\n </KameleoonContext.Provider>\n );\n}\n\nexport default memo(KameleoonProvider);\n"],"mappings":"uKAcA,QAAS,CAAAA,iBAAiBA,CAAAC,CAAA,CAGe,IAHd,CACzBC,MAAM,CAANA,CAAM,CACNC,QAAQ,CAARA,CACuB,CAAC,CAAAF,CAAA,CACxB,MACE,CAAAG,KAAA,CAAAC,aAAA,CAACC,iBAAA,CAAAC,gBAAgB,CAACC,QAAQ,EAACC,KAAK,CAAEP,CAAO,EACtCC,CACwB,CAE/B,CAAC,IAAAO,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEc,GAAAC,WAAI,EAACb,iBAAiB,CAAC"}
1
+ {"version":3,"file":"KameleoonProvider.js","names":["KameleoonProvider","a","client","children","_react","default","createElement","_KameleoonContext","KameleoonContext","Provider","value","_default","exports","React","memo"],"sources":["../src/KameleoonProvider.tsx"],"sourcesContent":["import React from 'react';\nimport { KameleoonClient } from '@kameleoon/javascript-sdk';\nimport { KameleoonContext } from './KameleoonContext';\n\nexport interface IKameleoonProviderProps {\n /** Child elements of the provider. */\n children: React.ReactNode;\n /** An instance of Kameleoon SDK. */\n client: KameleoonClient;\n}\n\n/**\n * A Provider that wraps the project and provides an access to SDK APIs\n */\nfunction KameleoonProvider({\n client,\n children,\n}: IKameleoonProviderProps): React.JSX.Element {\n return (\n <KameleoonContext.Provider value={client}>\n {children}\n </KameleoonContext.Provider>\n );\n}\n\nexport default React.memo(KameleoonProvider);\n"],"mappings":"uQAcA,QAAS,CAAAA,iBAAiBA,CAAAC,CAAA,CAGqB,IAHpB,CACzBC,MAAM,CAANA,CAAM,CACNC,QAAQ,CAARA,CACuB,CAAC,CAAAF,CAAA,CACxB,MACE,CAAAG,MAAA,CAAAC,OAAA,CAAAC,aAAA,CAACC,iBAAA,CAAAC,gBAAgB,CAACC,QAAQ,EAACC,KAAK,CAAER,CAAO,EACtCC,CACwB,CAE/B,CAAC,IAAAQ,QAAA,CAAAC,OAAA,CAAAP,OAAA,CAEcQ,cAAK,CAACC,IAAI,CAACd,iBAAiB,CAAC"}
@@ -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.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.1.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":""}
@@ -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":""}
@@ -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.0",
3
+ "version": "9.1.0",
4
4
  "description": "Kameleoon React SDK",
5
5
  "files": [
6
6
  "dist"
@@ -18,7 +18,7 @@
18
18
  "update-documentation": "/bin/bash ../../scripts/update_documentation.sh react-sdk",
19
19
  "update-changelog": "/bin/bash ../../scripts/update_changelog.sh react-sdk",
20
20
  "symlink": "yarn link",
21
- "test": "NODE_ENV=test && jest",
21
+ "test": "jest",
22
22
  "test:dev": "jest",
23
23
  "test:watch": "jest --watch",
24
24
  "test:coverage": "jest --coverage"
@@ -35,9 +35,11 @@
35
35
  "react sdk"
36
36
  ],
37
37
  "license": "ISC",
38
+ "dependencies": {
39
+ "@kameleoon/javascript-sdk": "3.1.0"
40
+ },
38
41
  "peerDependencies": {
39
- "react": ">=16.8.0",
40
- "@kameleoon/javascript-sdk": "3.0.0"
42
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
41
43
  },
42
44
  "devDependencies": {
43
45
  "@testing-library/jest-dom": "^5.16.5",