@kameleoon/react-sdk 6.1.3 → 7.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/README.md +8 -1
- package/dist/eventSource/nativeEventSource.js +2 -2
- package/dist/eventSource/nativeEventSource.js.map +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.js +68 -3
- package/dist/index.js.map +1 -1
- package/dist/kameleoonClient.js +2 -2
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonUtils/nativeUtils.js +0 -1
- package/dist/kameleoonUtils/nativeUtils.js.map +1 -1
- package/dist/useAddData.d.ts +7 -5
- package/dist/useAddData.js +3 -13
- package/dist/useAddData.js.map +1 -1
- package/dist/useBrowserVisitorCode.d.ts +4 -5
- package/dist/useBrowserVisitorCode.js +1 -1
- package/dist/useBrowserVisitorCode.js.map +1 -1
- package/dist/useConfigurationUpdate.d.ts +4 -4
- package/dist/useConfigurationUpdate.js +3 -13
- package/dist/useConfigurationUpdate.js.map +1 -1
- package/dist/useEngineTrackingCode.d.ts +5 -0
- package/dist/useEngineTrackingCode.js +20 -0
- package/dist/useEngineTrackingCode.js.map +1 -0
- package/dist/useExperimentVariationData.d.ts +21 -0
- package/dist/useExperimentVariationData.js +25 -0
- package/dist/useExperimentVariationData.js.map +1 -0
- package/dist/useExperiments.d.ts +4 -4
- package/dist/useExperiments.js +3 -14
- package/dist/useExperiments.js.map +1 -1
- package/dist/useFeatureFlagActive.d.ts +8 -4
- package/dist/useFeatureFlagActive.js +3 -14
- package/dist/useFeatureFlagActive.js.map +1 -1
- package/dist/useFeatureFlagVariationKey.d.ts +10 -7
- package/dist/useFeatureFlagVariationKey.js +3 -14
- package/dist/useFeatureFlagVariationKey.js.map +1 -1
- package/dist/useFeatureFlags.d.ts +4 -4
- package/dist/useFeatureFlags.js +3 -14
- package/dist/useFeatureFlags.js.map +1 -1
- package/dist/useFeatureVariable.d.ts +11 -6
- package/dist/useFeatureVariable.js +3 -14
- package/dist/useFeatureVariable.js.map +1 -1
- package/dist/useFlushData.d.ts +3 -0
- package/dist/useFlushData.js.map +1 -1
- package/dist/useInitialize.d.ts +5 -4
- package/dist/useInitialize.js +3 -14
- package/dist/useInitialize.js.map +1 -1
- package/dist/useKameleoon.d.ts +2 -1
- package/dist/useKameleoon.js +3 -3
- package/dist/useKameleoon.js.map +1 -1
- package/dist/useNativeVisitorCode.d.ts +3 -4
- package/dist/useNativeVisitorCode.js +1 -1
- package/dist/useNativeVisitorCode.js.map +1 -1
- package/dist/useRemoteData.d.ts +5 -5
- package/dist/useRemoteData.js +2 -14
- package/dist/useRemoteData.js.map +1 -1
- package/dist/useTrackConversion.d.ts +4 -3
- package/dist/useTrackConversion.js +2 -12
- package/dist/useTrackConversion.js.map +1 -1
- package/dist/useTriggerExperiment.d.ts +7 -3
- package/dist/useTriggerExperiment.js +3 -15
- package/dist/useTriggerExperiment.js.map +1 -1
- package/dist/useVisitorExperiments.d.ts +7 -6
- package/dist/useVisitorExperiments.js +3 -14
- package/dist/useVisitorExperiments.js.map +1 -1
- package/dist/useVisitorFeatureFlags.d.ts +6 -4
- package/dist/useVisitorFeatureFlags.js +3 -14
- package/dist/useVisitorFeatureFlags.js.map +1 -1
- package/package.json +3 -2
- package/dist/KameleoonError.d.ts +0 -5
- package/dist/KameleoonError.js +0 -20
- package/dist/KameleoonError.js.map +0 -1
- package/dist/ProviderError.d.ts +0 -3
- package/dist/ProviderError.js +0 -14
- package/dist/ProviderError.js.map +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -9
- package/dist/constants.js.map +0 -1
- package/dist/useError.d.ts +0 -7
- package/dist/useError.js +0 -18
- package/dist/useError.js.map +0 -1
- package/dist/useErrors.d.ts +0 -7
- package/dist/useErrors.js +0 -19
- package/dist/useErrors.js.map +0 -1
package/dist/useExperiments.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ExperimentType } from '@kameleoon/javascript-sdk-core';
|
|
2
|
-
import { KameleoonError } from './KameleoonError';
|
|
3
2
|
export interface IExperimentsHookResult {
|
|
4
3
|
/**
|
|
5
4
|
* Returns a list of experiments stored in the client configuration.
|
|
6
5
|
*
|
|
7
6
|
* @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields.
|
|
7
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
8
|
+
*
|
|
9
|
+
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
|
|
8
10
|
*/
|
|
9
11
|
getExperiments: () => ExperimentType[];
|
|
10
|
-
/** An optional error object that may be returned if an error occurs while calling the `getExperiments` function. */
|
|
11
|
-
error: KameleoonError | null;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* A React Hook that returns `getExperiments` function which returns a list of experiments.
|
|
15
15
|
*
|
|
16
|
-
* @returns {IExperimentsHookResult} an object containing the `getExperiments` function
|
|
16
|
+
* @returns {IExperimentsHookResult} an object containing the `getExperiments` function.
|
|
17
17
|
*/
|
|
18
18
|
export declare function useExperiments(): IExperimentsHookResult;
|
package/dist/useExperiments.js
CHANGED
|
@@ -6,31 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useExperiments = useExperiments;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _useKameleoon = require("./useKameleoon");
|
|
9
|
-
var _useError = require("./useError");
|
|
10
9
|
/**
|
|
11
10
|
* A React Hook that returns `getExperiments` function which returns a list of experiments.
|
|
12
11
|
*
|
|
13
|
-
* @returns {IExperimentsHookResult} an object containing the `getExperiments` function
|
|
12
|
+
* @returns {IExperimentsHookResult} an object containing the `getExperiments` function.
|
|
14
13
|
*/
|
|
15
14
|
function useExperiments() {
|
|
16
15
|
const {
|
|
17
16
|
client
|
|
18
17
|
} = (0, _useKameleoon.useKameleoon)();
|
|
19
|
-
const {
|
|
20
|
-
error,
|
|
21
|
-
setError
|
|
22
|
-
} = (0, _useError.useError)();
|
|
23
18
|
const getExperiments = (0, _react.useCallback)(() => {
|
|
24
|
-
|
|
25
|
-
return client.getExperiments();
|
|
26
|
-
} catch (unknownError) {
|
|
27
|
-
setError(unknownError);
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
19
|
+
return client.getExperiments();
|
|
30
20
|
}, [client]);
|
|
31
21
|
return {
|
|
32
|
-
getExperiments
|
|
33
|
-
error
|
|
22
|
+
getExperiments
|
|
34
23
|
};
|
|
35
24
|
}
|
|
36
25
|
//# sourceMappingURL=useExperiments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExperiments.js","names":["_react","require","_useKameleoon","
|
|
1
|
+
{"version":3,"file":"useExperiments.js","names":["_react","require","_useKameleoon","useExperiments","client","useKameleoon","getExperiments","useCallback"],"sources":["../src/useExperiments.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { ExperimentType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IExperimentsHookResult {\n /**\n * Returns a list of experiments stored in the client configuration.\n *\n * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n */\n getExperiments: () => ExperimentType[];\n}\n\n/**\n * A React Hook that returns `getExperiments` function which returns a list of experiments.\n *\n * @returns {IExperimentsHookResult} an object containing the `getExperiments` function.\n */\nexport function useExperiments(): IExperimentsHookResult {\n const { client } = useKameleoon();\n\n const getExperiments = useCallback((): ExperimentType[] => {\n return client.getExperiments();\n }, [client]);\n\n return {\n getExperiments,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAcA;AACA;AACA;AACA;AACA;AACO,SAASE,cAAcA,CAAA,EAA2B;EACvD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EAEjC,MAAMC,cAAc,GAAG,IAAAC,kBAAW,EAAC,MAAwB;IACzD,OAAOH,MAAM,CAACE,cAAc,EAAE;EAChC,CAAC,EAAE,CAACF,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLE;EACF,CAAC;AACH"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import { KameleoonError } from './KameleoonError';
|
|
2
1
|
export interface IFeatureFlagActiveHookResult {
|
|
3
2
|
/**
|
|
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
|
|
3
|
+
* 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
4
|
*
|
|
6
5
|
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.
|
|
7
6
|
* @param {string} featureKey - a unique key for feature flag.
|
|
8
7
|
* @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`.
|
|
8
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
9
|
+
*
|
|
10
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.
|
|
11
|
+
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
|
|
12
|
+
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`.
|
|
13
|
+
* - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.
|
|
14
|
+
* - `KameleoonException.NotTargeted` - Current visitor is not targeted.
|
|
9
15
|
*/
|
|
10
16
|
isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;
|
|
11
|
-
/** An optional error object that may be returned if an error occurs while calling the `isFeatureFlagActive` function. */
|
|
12
|
-
error: KameleoonError | null;
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
15
19
|
* A React Hook that returns `isFeatureFlagActive` function which indicates whether the visitor with `visitorCode` has `featureKey` active for him.
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useFeatureFlagActive = useFeatureFlagActive;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _useKameleoon = require("./useKameleoon");
|
|
9
|
-
var _useError = require("./useError");
|
|
10
9
|
/**
|
|
11
10
|
* A React Hook that returns `isFeatureFlagActive` function which indicates whether the visitor with `visitorCode` has `featureKey` active for him.
|
|
12
11
|
*
|
|
@@ -16,21 +15,11 @@ function useFeatureFlagActive() {
|
|
|
16
15
|
const {
|
|
17
16
|
client
|
|
18
17
|
} = (0, _useKameleoon.useKameleoon)();
|
|
19
|
-
const {
|
|
20
|
-
error,
|
|
21
|
-
setError
|
|
22
|
-
} = (0, _useError.useError)();
|
|
23
18
|
const isFeatureFlagActive = (0, _react.useCallback)((visitorCode, featureKey) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} catch (unknownError) {
|
|
27
|
-
setError(unknownError);
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}, [client, setError]);
|
|
19
|
+
return client.isFeatureFlagActive(visitorCode, featureKey);
|
|
20
|
+
}, [client]);
|
|
31
21
|
return {
|
|
32
|
-
isFeatureFlagActive
|
|
33
|
-
error
|
|
22
|
+
isFeatureFlagActive
|
|
34
23
|
};
|
|
35
24
|
}
|
|
36
25
|
//# sourceMappingURL=useFeatureFlagActive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFeatureFlagActive.js","names":["_react","require","_useKameleoon","
|
|
1
|
+
{"version":3,"file":"useFeatureFlagActive.js","names":["_react","require","_useKameleoon","useFeatureFlagActive","client","useKameleoon","isFeatureFlagActive","useCallback","visitorCode","featureKey"],"sources":["../src/useFeatureFlagActive.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFeatureFlagActiveHookResult {\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.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `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\n/**\n * A React Hook that returns `isFeatureFlagActive` function which indicates whether the visitor with `visitorCode` has `featureKey` active for him.\n *\n * @returns {IFeatureFlagActiveHookResult} an object containing the `isFeatureFlagActive` function.\n */\nexport function useFeatureFlagActive(): IFeatureFlagActiveHookResult {\n const { client } = useKameleoon();\n\n const isFeatureFlagActive = useCallback(\n (visitorCode: string, featureKey: string): boolean => {\n return client.isFeatureFlagActive(visitorCode, featureKey);\n },\n [client],\n );\n\n return {\n isFeatureFlagActive,\n };\n}"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAoBA;AACA;AACA;AACA;AACA;AACO,SAASE,oBAAoBA,CAAA,EAAiC;EACnE,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EAEjC,MAAMC,mBAAmB,GAAG,IAAAC,kBAAW,EACrC,CAACC,WAAmB,EAAEC,UAAkB,KAAc;IACpD,OAAOL,MAAM,CAACE,mBAAmB,CAACE,WAAW,EAAEC,UAAU,CAAC;EAC5D,CAAC,EACD,CAACL,MAAM,CAAC,CACT;EAED,OAAO;IACLE;EACF,CAAC;AACH"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { KameleoonError } from './KameleoonError';
|
|
2
1
|
export interface IFeatureFlagVariationKeyHookResult {
|
|
3
2
|
/**
|
|
4
|
-
* 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
|
|
3
|
+
* 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.
|
|
5
4
|
*
|
|
6
5
|
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.
|
|
7
6
|
* @param {string} featureKey - a unique key for feature flag.
|
|
8
|
-
* @returns {string
|
|
7
|
+
* @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor.
|
|
8
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
9
|
+
*
|
|
10
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.
|
|
11
|
+
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
|
|
12
|
+
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`.
|
|
13
|
+
* - `KameleoonException.NotTargeted` - Current visitor is not targeted.
|
|
9
14
|
*/
|
|
10
|
-
getFeatureFlagVariationKey: (visitorCode: string, featureKey: string) => string
|
|
11
|
-
/** An optional error object that may be returned if an error occurs while calling the `getFeatureFlagVariationKey` function. */
|
|
12
|
-
error: KameleoonError | null;
|
|
15
|
+
getFeatureFlagVariationKey: (visitorCode: string, featureKey: string) => string;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
15
18
|
* A React Hook that returns `getFeatureFlagVariationKey` function which returns variation key for the visitor under `visitorCode` in the found feature flag.
|
|
16
19
|
*
|
|
17
|
-
* @returns {IFeatureFlagVariationKeyHookResult} an object containing the `getFeatureFlagVariationKey` function
|
|
20
|
+
* @returns {IFeatureFlagVariationKeyHookResult} an object containing the `getFeatureFlagVariationKey` function.
|
|
18
21
|
*/
|
|
19
22
|
export declare function useFeatureFlagVariationKey(): IFeatureFlagVariationKeyHookResult;
|
|
@@ -6,31 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useFeatureFlagVariationKey = useFeatureFlagVariationKey;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _useKameleoon = require("./useKameleoon");
|
|
9
|
-
var _useError = require("./useError");
|
|
10
9
|
/**
|
|
11
10
|
* A React Hook that returns `getFeatureFlagVariationKey` function which returns variation key for the visitor under `visitorCode` in the found feature flag.
|
|
12
11
|
*
|
|
13
|
-
* @returns {IFeatureFlagVariationKeyHookResult} an object containing the `getFeatureFlagVariationKey` function
|
|
12
|
+
* @returns {IFeatureFlagVariationKeyHookResult} an object containing the `getFeatureFlagVariationKey` function.
|
|
14
13
|
*/
|
|
15
14
|
function useFeatureFlagVariationKey() {
|
|
16
15
|
const {
|
|
17
16
|
client
|
|
18
17
|
} = (0, _useKameleoon.useKameleoon)();
|
|
19
|
-
const {
|
|
20
|
-
error,
|
|
21
|
-
setError
|
|
22
|
-
} = (0, _useError.useError)();
|
|
23
18
|
const getFeatureFlagVariationKey = (0, _react.useCallback)((visitorCode, featureKey) => {
|
|
24
|
-
|
|
25
|
-
return client.getFeatureFlagVariationKey(visitorCode, featureKey);
|
|
26
|
-
} catch (unknownError) {
|
|
27
|
-
setError(unknownError);
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
19
|
+
return client.getFeatureFlagVariationKey(visitorCode, featureKey);
|
|
30
20
|
}, [client]);
|
|
31
21
|
return {
|
|
32
|
-
getFeatureFlagVariationKey
|
|
33
|
-
error
|
|
22
|
+
getFeatureFlagVariationKey
|
|
34
23
|
};
|
|
35
24
|
}
|
|
36
25
|
//# sourceMappingURL=useFeatureFlagVariationKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFeatureFlagVariationKey.js","names":["_react","require","_useKameleoon","
|
|
1
|
+
{"version":3,"file":"useFeatureFlagVariationKey.js","names":["_react","require","_useKameleoon","useFeatureFlagVariationKey","client","useKameleoon","getFeatureFlagVariationKey","useCallback","visitorCode","featureKey"],"sources":["../src/useFeatureFlagVariationKey.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFeatureFlagVariationKeyHookResult {\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.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string;\n}\n\n/**\n * A React Hook that returns `getFeatureFlagVariationKey` function which returns variation key for the visitor under `visitorCode` in the found feature flag.\n *\n * @returns {IFeatureFlagVariationKeyHookResult} an object containing the `getFeatureFlagVariationKey` function.\n */\nexport function useFeatureFlagVariationKey(): IFeatureFlagVariationKeyHookResult {\n const { client } = useKameleoon();\n\n const getFeatureFlagVariationKey = useCallback(\n (visitorCode: string, featureKey: string): string => {\n return client.getFeatureFlagVariationKey(visitorCode, featureKey);\n },\n [client],\n );\n\n return {\n getFeatureFlagVariationKey,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAsBA;AACA;AACA;AACA;AACA;AACO,SAASE,0BAA0BA,CAAA,EAAuC;EAC/E,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EAEjC,MAAMC,0BAA0B,GAAG,IAAAC,kBAAW,EAC5C,CAACC,WAAmB,EAAEC,UAAkB,KAAa;IACnD,OAAOL,MAAM,CAACE,0BAA0B,CAACE,WAAW,EAAEC,UAAU,CAAC;EACnE,CAAC,EACD,CAACL,MAAM,CAAC,CACT;EAED,OAAO;IACLE;EACF,CAAC;AACH"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { FeatureFlagType } from '@kameleoon/javascript-sdk-core';
|
|
2
|
-
import { KameleoonError } from './KameleoonError';
|
|
3
2
|
export interface IFeatureFlagsHookResult {
|
|
4
3
|
/**
|
|
5
4
|
* Returns a list of feature flags stored in the client configuration.
|
|
6
5
|
*
|
|
7
6
|
* @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.
|
|
7
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
8
|
+
*
|
|
9
|
+
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
|
|
8
10
|
*/
|
|
9
11
|
getFeatureFlags: () => FeatureFlagType[];
|
|
10
|
-
/** An optional error object that may be returned if an error occurs while calling the `getFeatureFlags` function. */
|
|
11
|
-
error: KameleoonError | null;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* A React Hook that returns `getFeatureFlags` function which returns a list of feature flags.
|
|
15
15
|
*
|
|
16
|
-
* @returns {IFeatureFlagsHookResult} an object containing the `getFeatureFlags` function
|
|
16
|
+
* @returns {IFeatureFlagsHookResult} an object containing the `getFeatureFlags` function.
|
|
17
17
|
*/
|
|
18
18
|
export declare function useFeatureFlags(): IFeatureFlagsHookResult;
|
package/dist/useFeatureFlags.js
CHANGED
|
@@ -6,31 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useFeatureFlags = useFeatureFlags;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _useKameleoon = require("./useKameleoon");
|
|
9
|
-
var _useError = require("./useError");
|
|
10
9
|
/**
|
|
11
10
|
* A React Hook that returns `getFeatureFlags` function which returns a list of feature flags.
|
|
12
11
|
*
|
|
13
|
-
* @returns {IFeatureFlagsHookResult} an object containing the `getFeatureFlags` function
|
|
12
|
+
* @returns {IFeatureFlagsHookResult} an object containing the `getFeatureFlags` function.
|
|
14
13
|
*/
|
|
15
14
|
function useFeatureFlags() {
|
|
16
15
|
const {
|
|
17
16
|
client
|
|
18
17
|
} = (0, _useKameleoon.useKameleoon)();
|
|
19
|
-
const {
|
|
20
|
-
error,
|
|
21
|
-
setError
|
|
22
|
-
} = (0, _useError.useError)();
|
|
23
18
|
const getFeatureFlags = (0, _react.useCallback)(() => {
|
|
24
|
-
|
|
25
|
-
return client.getFeatureFlags();
|
|
26
|
-
} catch (unknownError) {
|
|
27
|
-
setError(unknownError);
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
19
|
+
return client.getFeatureFlags();
|
|
30
20
|
}, [client]);
|
|
31
21
|
return {
|
|
32
|
-
getFeatureFlags
|
|
33
|
-
error
|
|
22
|
+
getFeatureFlags
|
|
34
23
|
};
|
|
35
24
|
}
|
|
36
25
|
//# sourceMappingURL=useFeatureFlags.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFeatureFlags.js","names":["_react","require","_useKameleoon","
|
|
1
|
+
{"version":3,"file":"useFeatureFlags.js","names":["_react","require","_useKameleoon","useFeatureFlags","client","useKameleoon","getFeatureFlags","useCallback"],"sources":["../src/useFeatureFlags.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { FeatureFlagType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFeatureFlagsHookResult {\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 `initialize` was done for `kameleoonClient`.\n */\n getFeatureFlags: () => FeatureFlagType[];\n}\n\n/**\n * A React Hook that returns `getFeatureFlags` function which returns a list of feature flags.\n *\n * @returns {IFeatureFlagsHookResult} an object containing the `getFeatureFlags` function.\n */\nexport function useFeatureFlags(): IFeatureFlagsHookResult {\n const { client } = useKameleoon();\n\n const getFeatureFlags = useCallback((): FeatureFlagType[] => {\n return client.getFeatureFlags();\n }, [client]);\n\n return {\n getFeatureFlags,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAcA;AACA;AACA;AACA;AACA;AACO,SAASE,eAAeA,CAAA,EAA4B;EACzD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EAEjC,MAAMC,eAAe,GAAG,IAAAC,kBAAW,EAAC,MAAyB;IAC3D,OAAOH,MAAM,CAACE,eAAe,EAAE;EACjC,CAAC,EAAE,CAACF,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLE;EACF,CAAC;AACH"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { GetFeatureFlagVariableParamsType, FeatureVariableResultType } from '@kameleoon/javascript-sdk-core';
|
|
2
|
-
import { KameleoonError } from './KameleoonError';
|
|
3
2
|
export interface IFeatureVariableHookResult {
|
|
4
3
|
/**
|
|
5
|
-
* 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
|
|
4
|
+
* 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.
|
|
6
5
|
*
|
|
7
6
|
* @param {GetFeatureFlagVariableParamsType} params - `visitorCode`, `featureKey` and `variableKey` parameters to return variable.
|
|
8
|
-
* @return {FeatureVariableResultType
|
|
7
|
+
* @return {FeatureVariableResultType} a variable object containing `type` and `value` fields, `type` can be checked against `FeatureVariableType` enum, if the `type` is `FeatureVariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
|
|
8
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
9
|
+
*
|
|
10
|
+
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.
|
|
11
|
+
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
|
|
12
|
+
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`.
|
|
13
|
+
* - `KameleoonException.NotTargeted` - Current visitor is not targeted.
|
|
14
|
+
* - `KameleoonException.JSONParse` - Couldn't pass JSON value.
|
|
15
|
+
* - `KameleoonException.NumberParse` - Couldn't pass Number value.
|
|
9
16
|
*/
|
|
10
|
-
getFeatureFlagVariable: (params: GetFeatureFlagVariableParamsType) => FeatureVariableResultType
|
|
11
|
-
/** An optional error object that may be returned if an error occurs while calling the `getFeatureFlagVariable` function. */
|
|
12
|
-
error: KameleoonError | null;
|
|
17
|
+
getFeatureFlagVariable: (params: GetFeatureFlagVariableParamsType) => FeatureVariableResultType;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* A React Hook that returns `getFeatureFlagVariable` function which retrieves a feature variable.
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useFeatureVariable = useFeatureVariable;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _useKameleoon = require("./useKameleoon");
|
|
9
|
-
var _useError = require("./useError");
|
|
10
9
|
/**
|
|
11
10
|
* A React Hook that returns `getFeatureFlagVariable` function which retrieves a feature variable.
|
|
12
11
|
*
|
|
@@ -16,21 +15,11 @@ function useFeatureVariable() {
|
|
|
16
15
|
const {
|
|
17
16
|
client
|
|
18
17
|
} = (0, _useKameleoon.useKameleoon)();
|
|
19
|
-
const {
|
|
20
|
-
error,
|
|
21
|
-
setError
|
|
22
|
-
} = (0, _useError.useError)();
|
|
23
18
|
const getFeatureFlagVariable = (0, _react.useCallback)(params => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} catch (unknownError) {
|
|
27
|
-
setError(unknownError);
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
}, [client, setError]);
|
|
19
|
+
return client.getFeatureFlagVariable(params);
|
|
20
|
+
}, [client]);
|
|
31
21
|
return {
|
|
32
|
-
getFeatureFlagVariable
|
|
33
|
-
error
|
|
22
|
+
getFeatureFlagVariable
|
|
34
23
|
};
|
|
35
24
|
}
|
|
36
25
|
//# sourceMappingURL=useFeatureVariable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFeatureVariable.js","names":["_react","require","_useKameleoon","
|
|
1
|
+
{"version":3,"file":"useFeatureVariable.js","names":["_react","require","_useKameleoon","useFeatureVariable","client","useKameleoon","getFeatureFlagVariable","useCallback","params"],"sources":["../src/useFeatureVariable.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport {\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n} from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFeatureVariableHookResult {\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 {FeatureVariableResultType} a variable object containing `type` and `value` fields, `type` can be checked against `FeatureVariableType` enum, if the `type` is `FeatureVariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`.\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 ) => FeatureVariableResultType;\n}\n\n/**\n * A React Hook that returns `getFeatureFlagVariable` function which retrieves a feature variable.\n *\n * @returns {IPageViewHookResult} an object containing the `getFeatureFlagVariable` function.\n */\nexport function useFeatureVariable(): IFeatureVariableHookResult {\n const { client } = useKameleoon();\n\n const getFeatureFlagVariable = useCallback(\n (params: GetFeatureFlagVariableParamsType): FeatureVariableResultType => {\n return client.getFeatureFlagVariable(params);\n },\n [client],\n );\n\n return {\n getFeatureFlagVariable,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAD,OAAA;AAsBA;AACA;AACA;AACA;AACA;AACO,SAASE,kBAAkBA,CAAA,EAA+B;EAC/D,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EAEjC,MAAMC,sBAAsB,GAAG,IAAAC,kBAAW,EACvCC,MAAwC,IAAgC;IACvE,OAAOJ,MAAM,CAACE,sBAAsB,CAACE,MAAM,CAAC;EAC9C,CAAC,EACD,CAACJ,MAAM,CAAC,CACT;EAED,OAAO;IACLE;EACF,CAAC;AACH"}
|
package/dist/useFlushData.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export interface IFlushDataHookResult {
|
|
|
3
3
|
* 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.
|
|
4
4
|
*
|
|
5
5
|
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.
|
|
6
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
7
|
+
*
|
|
8
|
+
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
|
|
6
9
|
*/
|
|
7
10
|
flushData: (visitorCode: string) => void;
|
|
8
11
|
}
|
package/dist/useFlushData.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFlushData.js","names":["_react","require","_useKameleoon","useFlushData","client","useKameleoon","flushData","useCallback","visitorCode"],"sources":["../src/useFlushData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFlushDataHookResult {\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 *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n */\n flushData: (visitorCode: string) => void;\n}\n\n/**\n * A React Hook that returns `flushData` function\n *\n * @returns {IFlushDataHookResult} an object containing the `flushData` function.\n */\nexport function useFlushData(): IFlushDataHookResult {\n const { client } = useKameleoon();\n\n const flushData = useCallback(\n (visitorCode: string): void => {\n client.flushData(visitorCode);\n },\n [client],\n );\n\n return {\n flushData,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;
|
|
1
|
+
{"version":3,"file":"useFlushData.js","names":["_react","require","_useKameleoon","useFlushData","client","useKameleoon","flushData","useCallback","visitorCode"],"sources":["../src/useFlushData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFlushDataHookResult {\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 *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n */\n flushData: (visitorCode: string) => void;\n}\n\n/**\n * A React Hook that returns `flushData` function\n *\n * @returns {IFlushDataHookResult} an object containing the `flushData` function.\n */\nexport function useFlushData(): IFlushDataHookResult {\n const { client } = useKameleoon();\n\n const flushData = useCallback(\n (visitorCode: string): void => {\n client.flushData(visitorCode);\n },\n [client],\n );\n\n return {\n flushData,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAcA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAAA,EAAyB;EACnD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EAEjC,MAAMC,SAAS,GAAG,IAAAC,kBAAW,EAC1BC,WAAmB,IAAW;IAC7BJ,MAAM,CAACE,SAAS,CAACE,WAAW,CAAC;EAC/B,CAAC,EACD,CAACJ,MAAM,CAAC,CACT;EAED,OAAO;IACLE;EACF,CAAC;AACH"}
|
package/dist/useInitialize.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { KameleoonError } from './KameleoonError';
|
|
2
1
|
export interface IInitializeHookResult {
|
|
3
2
|
/**
|
|
4
3
|
* 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.
|
|
4
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
5
|
+
*
|
|
6
|
+
* - `KameleoonException.StorageWrite` Couldn't update storage data.
|
|
7
|
+
* - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api.
|
|
5
8
|
*/
|
|
6
9
|
initialize: () => Promise<boolean>;
|
|
7
|
-
/** An optional error object that may be returned if an error occurs while calling the `initialize` function. */
|
|
8
|
-
error: KameleoonError | null;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* A React Hook that returns asynchronous `initialize` function.
|
|
12
13
|
*
|
|
13
|
-
* @returns {IInitializeHookResult} an object containing the asynchronous `initialize` function
|
|
14
|
+
* @returns {IInitializeHookResult} an object containing the asynchronous `initialize` function.
|
|
14
15
|
*/
|
|
15
16
|
export declare function useInitialize(): IInitializeHookResult;
|
package/dist/useInitialize.js
CHANGED
|
@@ -6,31 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useInitialize = useInitialize;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _useKameleoon = require("./useKameleoon");
|
|
9
|
-
var _useError = require("./useError");
|
|
10
9
|
/**
|
|
11
10
|
* A React Hook that returns asynchronous `initialize` function.
|
|
12
11
|
*
|
|
13
|
-
* @returns {IInitializeHookResult} an object containing the asynchronous `initialize` function
|
|
12
|
+
* @returns {IInitializeHookResult} an object containing the asynchronous `initialize` function.
|
|
14
13
|
*/
|
|
15
14
|
function useInitialize() {
|
|
16
15
|
const {
|
|
17
16
|
client
|
|
18
17
|
} = (0, _useKameleoon.useKameleoon)();
|
|
19
|
-
const {
|
|
20
|
-
error,
|
|
21
|
-
setError
|
|
22
|
-
} = (0, _useError.useError)();
|
|
23
18
|
const initialize = (0, _react.useCallback)(async () => {
|
|
24
|
-
|
|
25
|
-
return await client.initialize();
|
|
26
|
-
} catch (unknownError) {
|
|
27
|
-
setError(unknownError);
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
19
|
+
return await client.initialize();
|
|
30
20
|
}, [client]);
|
|
31
21
|
return {
|
|
32
|
-
initialize
|
|
33
|
-
error
|
|
22
|
+
initialize
|
|
34
23
|
};
|
|
35
24
|
}
|
|
36
25
|
//# sourceMappingURL=useInitialize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialize.js","names":["_react","require","_useKameleoon","
|
|
1
|
+
{"version":3,"file":"useInitialize.js","names":["_react","require","_useKameleoon","useInitialize","client","useKameleoon","initialize","useCallback"],"sources":["../src/useInitialize.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IInitializeHookResult {\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 * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.StorageWrite` Couldn't update storage data.\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api.\n */\n initialize: () => Promise<boolean>;\n}\n\n/**\n * A React Hook that returns asynchronous `initialize` function.\n *\n * @returns {IInitializeHookResult} an object containing the asynchronous `initialize` function.\n */\nexport function useInitialize(): IInitializeHookResult {\n const { client } = useKameleoon();\n\n const initialize = useCallback(async (): Promise<boolean> => {\n return await client.initialize();\n }, [client]);\n\n return {\n initialize,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAaA;AACA;AACA;AACA;AACA;AACO,SAASE,aAAaA,CAAA,EAA0B;EACrD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EAEjC,MAAMC,UAAU,GAAG,IAAAC,kBAAW,EAAC,YAA8B;IAC3D,OAAO,MAAMH,MAAM,CAACE,UAAU,EAAE;EAClC,CAAC,EAAE,CAACF,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLE;EACF,CAAC;AACH"}
|
package/dist/useKameleoon.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface IKameleoonHookResult {
|
|
|
6
6
|
/**
|
|
7
7
|
* A React Hook that validates if context is used within a KameleoonProvider and returns it.
|
|
8
8
|
*
|
|
9
|
-
* @returns {IKameleoonHookResult}
|
|
9
|
+
* @returns {IKameleoonHookResult} an object containing the `client` field.
|
|
10
|
+
* @throws useKameleoon must be used within a KameleoonProvider.
|
|
10
11
|
*/
|
|
11
12
|
export declare function useKameleoon(): IKameleoonHookResult;
|
package/dist/useKameleoon.js
CHANGED
|
@@ -6,16 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useKameleoon = useKameleoon;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _KameleoonContext = require("./KameleoonContext");
|
|
9
|
-
var _ProviderError = require("./ProviderError");
|
|
10
9
|
/**
|
|
11
10
|
* A React Hook that validates if context is used within a KameleoonProvider and returns it.
|
|
12
11
|
*
|
|
13
|
-
* @returns {IKameleoonHookResult}
|
|
12
|
+
* @returns {IKameleoonHookResult} an object containing the `client` field.
|
|
13
|
+
* @throws useKameleoon must be used within a KameleoonProvider.
|
|
14
14
|
*/
|
|
15
15
|
function useKameleoon() {
|
|
16
16
|
const context = (0, _react.useContext)(_KameleoonContext.KameleoonContext);
|
|
17
17
|
if (!context) {
|
|
18
|
-
throw new
|
|
18
|
+
throw new Error('useKameleoon must be used within a KameleoonProvider');
|
|
19
19
|
}
|
|
20
20
|
return {
|
|
21
21
|
client: context
|
package/dist/useKameleoon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKameleoon.js","names":["_react","require","_KameleoonContext","
|
|
1
|
+
{"version":3,"file":"useKameleoon.js","names":["_react","require","_KameleoonContext","useKameleoon","context","useContext","KameleoonContext","Error","client"],"sources":["../src/useKameleoon.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { KameleoonCore } from '@kameleoon/javascript-sdk-core';\nimport { KameleoonContext } from './KameleoonContext';\n\nexport interface IKameleoonHookResult {\n /** An instance of KameleoonClient. */\n client: KameleoonCore;\n}\n\n/**\n * A React Hook that validates if context is used within a KameleoonProvider and returns it.\n *\n * @returns {IKameleoonHookResult} an object containing the `client` field.\n * @throws useKameleoon must be used within a KameleoonProvider.\n */\nexport function useKameleoon(): IKameleoonHookResult {\n const context = useContext(KameleoonContext);\n\n if (!context) {\n throw new Error('useKameleoon must be used within a KameleoonProvider');\n }\n\n return {\n client: context,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAOA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAAA,EAAyB;EACnD,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACC,kCAAgB,CAAC;EAE5C,IAAI,CAACF,OAAO,EAAE;IACZ,MAAM,IAAIG,KAAK,CAAC,sDAAsD,CAAC;EACzE;EAEA,OAAO;IACLC,MAAM,EAAEJ;EACV,CAAC;AACH"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
interface INativeVisitorCodeHookResult {
|
|
1
|
+
export interface INativeVisitorCodeHookResult {
|
|
2
2
|
/**
|
|
3
3
|
* Obtains visitor code from the storage, if no visitor code exists returns a new random visitor code (or the specified default value).
|
|
4
4
|
*
|
|
5
|
-
* @param defaultVisitorCode - visitor code to be used instead of randomly generated visitor code in case there is no visitor code saved in storage.
|
|
5
|
+
* @param {string | undefined} defaultVisitorCode - visitor code to be used instead of randomly generated visitor code in case there is no visitor code saved in storage.
|
|
6
6
|
* @returns {string} result visitor code.
|
|
7
7
|
*/
|
|
8
8
|
getNativeVisitorCode: (defaultVisitorCode?: string) => string;
|
|
@@ -10,7 +10,6 @@ interface INativeVisitorCodeHookResult {
|
|
|
10
10
|
/**
|
|
11
11
|
* A React Hook that returns `getNativeVisitorCode function which obtains the Kameleoon visitorCode.
|
|
12
12
|
*
|
|
13
|
-
* @returns {INativeVisitorCodeHookResult} an object containing the `getNativeVisitorCode` function
|
|
13
|
+
* @returns {INativeVisitorCodeHookResult} an object containing the `getNativeVisitorCode` function.
|
|
14
14
|
*/
|
|
15
15
|
export declare function useNativeVisitorCode(): INativeVisitorCodeHookResult;
|
|
16
|
-
export {};
|
|
@@ -9,7 +9,7 @@ var _nativeUtils = require("./kameleoonUtils/nativeUtils");
|
|
|
9
9
|
/**
|
|
10
10
|
* A React Hook that returns `getNativeVisitorCode function which obtains the Kameleoon visitorCode.
|
|
11
11
|
*
|
|
12
|
-
* @returns {INativeVisitorCodeHookResult} an object containing the `getNativeVisitorCode` function
|
|
12
|
+
* @returns {INativeVisitorCodeHookResult} an object containing the `getNativeVisitorCode` function.
|
|
13
13
|
*/
|
|
14
14
|
function useNativeVisitorCode() {
|
|
15
15
|
const getNativeVisitorCode = (0, _react.useCallback)(defaultVisitorCode => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNativeVisitorCode.js","names":["_react","require","_nativeUtils","useNativeVisitorCode","getNativeVisitorCode","useCallback","defaultVisitorCode","NativeUtils","getVisitorCode"],"sources":["../src/useNativeVisitorCode.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { NativeUtils } from './kameleoonUtils/nativeUtils';\n\
|
|
1
|
+
{"version":3,"file":"useNativeVisitorCode.js","names":["_react","require","_nativeUtils","useNativeVisitorCode","getNativeVisitorCode","useCallback","defaultVisitorCode","NativeUtils","getVisitorCode"],"sources":["../src/useNativeVisitorCode.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { NativeUtils } from './kameleoonUtils/nativeUtils';\n\nexport interface INativeVisitorCodeHookResult {\n /**\n * Obtains visitor code from the storage, if no visitor code exists returns a new random visitor code (or the specified default value).\n *\n * @param {string | undefined} defaultVisitorCode - visitor code to be used instead of randomly generated visitor code in case there is no visitor code saved in storage.\n * @returns {string} result visitor code.\n */\n getNativeVisitorCode: (defaultVisitorCode?: string) => string;\n}\n\n/**\n * A React Hook that returns `getNativeVisitorCode function which obtains the Kameleoon visitorCode.\n *\n * @returns {INativeVisitorCodeHookResult} an object containing the `getNativeVisitorCode` function.\n */\nexport function useNativeVisitorCode(): INativeVisitorCodeHookResult {\n const getNativeVisitorCode = useCallback(\n (defaultVisitorCode?: string): string => {\n return NativeUtils.getVisitorCode(defaultVisitorCode);\n },\n [],\n );\n\n return {\n getNativeVisitorCode,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAYA;AACA;AACA;AACA;AACA;AACO,SAASE,oBAAoBA,CAAA,EAAiC;EACnE,MAAMC,oBAAoB,GAAG,IAAAC,kBAAW,EACrCC,kBAA2B,IAAa;IACvC,OAAOC,wBAAW,CAACC,cAAc,CAACF,kBAAkB,CAAC;EACvD,CAAC,EACD,EAAE,CACH;EAED,OAAO;IACLF;EACF,CAAC;AACH"}
|
package/dist/useRemoteData.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { JSONType } from '@kameleoon/javascript-sdk-core';
|
|
2
|
-
import { KameleoonError } from './KameleoonError';
|
|
3
2
|
export interface IRemoteDataHookResult {
|
|
4
3
|
/**
|
|
5
4
|
* Returns a data which is stored for specified siteCode on a remote Kameleoon server.
|
|
6
5
|
*
|
|
7
6
|
* @param {string} key - unique key that the data you try to get is associated with.
|
|
8
|
-
* @returns {Promise<JSONType
|
|
7
|
+
* @returns {Promise<JSONType>} promise with retrieving data for specific key.
|
|
8
|
+
* @throws `KameleoonError` with one of the following `type` s:
|
|
9
|
+
*
|
|
10
|
+
* - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server.
|
|
9
11
|
*/
|
|
10
|
-
getRemoteData: (key: string) => Promise<JSONType
|
|
11
|
-
/** An optional error object that may be returned if an error occurs while calling the `getRemoteData` function. */
|
|
12
|
-
error: KameleoonError | null;
|
|
12
|
+
getRemoteData: (key: string) => Promise<JSONType>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* A React Hook that returns asynchronous getRemoteData function which retrieves data from Kameleoon server.
|