@kameleoon/react-sdk 6.1.3 → 7.0.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.
Files changed (79) hide show
  1. package/README.md +8 -1
  2. package/dist/eventSource/nativeEventSource.js +2 -2
  3. package/dist/eventSource/nativeEventSource.js.map +1 -1
  4. package/dist/index.d.ts +8 -4
  5. package/dist/index.js +55 -3
  6. package/dist/index.js.map +1 -1
  7. package/dist/kameleoonClient.js +2 -2
  8. package/dist/kameleoonClient.js.map +1 -1
  9. package/dist/kameleoonUtils/nativeUtils.js +0 -1
  10. package/dist/kameleoonUtils/nativeUtils.js.map +1 -1
  11. package/dist/useAddData.d.ts +7 -5
  12. package/dist/useAddData.js +3 -13
  13. package/dist/useAddData.js.map +1 -1
  14. package/dist/useBrowserVisitorCode.d.ts +4 -5
  15. package/dist/useBrowserVisitorCode.js +1 -1
  16. package/dist/useBrowserVisitorCode.js.map +1 -1
  17. package/dist/useConfigurationUpdate.d.ts +4 -4
  18. package/dist/useConfigurationUpdate.js +3 -13
  19. package/dist/useConfigurationUpdate.js.map +1 -1
  20. package/dist/useExperimentVariationData.d.ts +21 -0
  21. package/dist/useExperimentVariationData.js +25 -0
  22. package/dist/useExperimentVariationData.js.map +1 -0
  23. package/dist/useExperiments.d.ts +4 -4
  24. package/dist/useExperiments.js +3 -14
  25. package/dist/useExperiments.js.map +1 -1
  26. package/dist/useFeatureFlagActive.d.ts +8 -4
  27. package/dist/useFeatureFlagActive.js +3 -14
  28. package/dist/useFeatureFlagActive.js.map +1 -1
  29. package/dist/useFeatureFlagVariationKey.d.ts +10 -7
  30. package/dist/useFeatureFlagVariationKey.js +3 -14
  31. package/dist/useFeatureFlagVariationKey.js.map +1 -1
  32. package/dist/useFeatureFlags.d.ts +4 -4
  33. package/dist/useFeatureFlags.js +3 -14
  34. package/dist/useFeatureFlags.js.map +1 -1
  35. package/dist/useFeatureVariable.d.ts +11 -6
  36. package/dist/useFeatureVariable.js +3 -14
  37. package/dist/useFeatureVariable.js.map +1 -1
  38. package/dist/useFlushData.d.ts +3 -0
  39. package/dist/useFlushData.js.map +1 -1
  40. package/dist/useInitialize.d.ts +5 -4
  41. package/dist/useInitialize.js +3 -14
  42. package/dist/useInitialize.js.map +1 -1
  43. package/dist/useKameleoon.d.ts +2 -1
  44. package/dist/useKameleoon.js +3 -3
  45. package/dist/useKameleoon.js.map +1 -1
  46. package/dist/useNativeVisitorCode.d.ts +3 -4
  47. package/dist/useNativeVisitorCode.js +1 -1
  48. package/dist/useNativeVisitorCode.js.map +1 -1
  49. package/dist/useRemoteData.d.ts +5 -5
  50. package/dist/useRemoteData.js +2 -14
  51. package/dist/useRemoteData.js.map +1 -1
  52. package/dist/useTrackConversion.d.ts +4 -3
  53. package/dist/useTrackConversion.js +2 -12
  54. package/dist/useTrackConversion.js.map +1 -1
  55. package/dist/useTriggerExperiment.d.ts +7 -3
  56. package/dist/useTriggerExperiment.js +3 -15
  57. package/dist/useTriggerExperiment.js.map +1 -1
  58. package/dist/useVisitorExperiments.d.ts +7 -6
  59. package/dist/useVisitorExperiments.js +3 -14
  60. package/dist/useVisitorExperiments.js.map +1 -1
  61. package/dist/useVisitorFeatureFlags.d.ts +6 -4
  62. package/dist/useVisitorFeatureFlags.js +3 -14
  63. package/dist/useVisitorFeatureFlags.js.map +1 -1
  64. package/package.json +3 -2
  65. package/dist/KameleoonError.d.ts +0 -5
  66. package/dist/KameleoonError.js +0 -20
  67. package/dist/KameleoonError.js.map +0 -1
  68. package/dist/ProviderError.d.ts +0 -3
  69. package/dist/ProviderError.js +0 -14
  70. package/dist/ProviderError.js.map +0 -1
  71. package/dist/constants.d.ts +0 -1
  72. package/dist/constants.js +0 -9
  73. package/dist/constants.js.map +0 -1
  74. package/dist/useError.d.ts +0 -7
  75. package/dist/useError.js +0 -18
  76. package/dist/useError.js.map +0 -1
  77. package/dist/useErrors.d.ts +0 -7
  78. package/dist/useErrors.js +0 -19
  79. package/dist/useErrors.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useExperiments.js","names":["_react","require","_useKameleoon","_useError","useExperiments","client","useKameleoon","error","setError","useError","getExperiments","useCallback","unknownError"],"sources":["../src/useExperiments.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { ExperimentType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\nimport { useError } from './useError';\nimport { KameleoonError } from './KameleoonError';\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 */\n getExperiments: () => ExperimentType[];\n /** An optional error object that may be returned if an error occurs while calling the `getExperiments` function. */\n error: KameleoonError | null;\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 and an optional error object.\n */\nexport function useExperiments(): IExperimentsHookResult {\n const { client } = useKameleoon();\n const { error, setError } = useError();\n\n const getExperiments = useCallback((): ExperimentType[] => {\n try {\n return client.getExperiments();\n } catch (unknownError) {\n setError(unknownError);\n\n return [];\n }\n }, [client]);\n\n return {\n getExperiments,\n error,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAcA;AACA;AACA;AACA;AACA;AACO,SAASG,cAAcA,CAAA,EAA2B;EACvD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EACjC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAG,IAAAC,kBAAQ,GAAE;EAEtC,MAAMC,cAAc,GAAG,IAAAC,kBAAW,EAAC,MAAwB;IACzD,IAAI;MACF,OAAON,MAAM,CAACK,cAAc,EAAE;IAChC,CAAC,CAAC,OAAOE,YAAY,EAAE;MACrBJ,QAAQ,CAACI,YAAY,CAAC;MAEtB,OAAO,EAAE;IACX;EACF,CAAC,EAAE,CAACP,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLK,cAAc;IACdH;EACF,CAAC;AACH"}
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 if the feature rollout rule was of type of `Experimentation`.
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
- try {
25
- return client.isFeatureFlagActive(visitorCode, featureKey);
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","_useError","useFeatureFlagActive","client","useKameleoon","error","setError","useError","isFeatureFlagActive","useCallback","visitorCode","featureKey","unknownError"],"sources":["../src/useFeatureFlagActive.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\nimport { KameleoonError } from './KameleoonError';\nimport { useError } from './useError';\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 if the feature rollout rule was of type of `Experimentation`.\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 */\n isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;\n /** An optional error object that may be returned if an error occurs while calling the `isFeatureFlagActive` function. */\n error: KameleoonError | null;\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 const { error, setError } = useError();\n\n const isFeatureFlagActive = useCallback(\n (visitorCode: string, featureKey: string): boolean => {\n try {\n return client.isFeatureFlagActive(visitorCode, featureKey);\n } catch (unknownError) {\n setError(unknownError);\n\n return false;\n }\n },\n [client, setError],\n );\n\n return {\n isFeatureFlagActive,\n error,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAeA;AACA;AACA;AACA;AACA;AACO,SAASG,oBAAoBA,CAAA,EAAiC;EACnE,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EACjC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAG,IAAAC,kBAAQ,GAAE;EAEtC,MAAMC,mBAAmB,GAAG,IAAAC,kBAAW,EACrC,CAACC,WAAmB,EAAEC,UAAkB,KAAc;IACpD,IAAI;MACF,OAAOR,MAAM,CAACK,mBAAmB,CAACE,WAAW,EAAEC,UAAU,CAAC;IAC5D,CAAC,CAAC,OAAOC,YAAY,EAAE;MACrBN,QAAQ,CAACM,YAAY,CAAC;MAEtB,OAAO,KAAK;IACd;EACF,CAAC,EACD,CAACT,MAAM,EAAEG,QAAQ,CAAC,CACnB;EAED,OAAO;IACLE,mBAAmB;IACnBH;EACF,CAAC;AACH"}
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 if the feature rollout rule was of type of `Experimentation`.
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 | undefined} a string containing variable key for the allocated feature flag variation for the provided visitor.
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 | undefined;
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 and an optional error object.
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 and an optional error object.
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
- try {
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","_useError","useFeatureFlagVariationKey","client","useKameleoon","error","setError","useError","getFeatureFlagVariationKey","useCallback","visitorCode","featureKey","unknownError","undefined"],"sources":["../src/useFeatureFlagVariationKey.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\nimport { useError } from './useError';\nimport { KameleoonError } from './KameleoonError';\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 if the feature rollout rule was of type of `Experimentation`.\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 | undefined} a string containing variable key for the allocated feature flag variation for the provided visitor.\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string | undefined;\n /** An optional error object that may be returned if an error occurs while calling the `getFeatureFlagVariationKey` function. */\n error: KameleoonError | null;\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 and an optional error object.\n */\nexport function useFeatureFlagVariationKey(): IFeatureFlagVariationKeyHookResult {\n const { client } = useKameleoon();\n const { error, setError } = useError();\n\n const getFeatureFlagVariationKey = useCallback(\n (visitorCode: string, featureKey: string): string | undefined => {\n try {\n return client.getFeatureFlagVariationKey(visitorCode, featureKey);\n } catch (unknownError) {\n setError(unknownError);\n\n return undefined;\n }\n },\n [client],\n );\n\n return {\n getFeatureFlagVariationKey,\n error,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAmBA;AACA;AACA;AACA;AACA;AACO,SAASG,0BAA0BA,CAAA,EAAuC;EAC/E,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EACjC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAG,IAAAC,kBAAQ,GAAE;EAEtC,MAAMC,0BAA0B,GAAG,IAAAC,kBAAW,EAC5C,CAACC,WAAmB,EAAEC,UAAkB,KAAyB;IAC/D,IAAI;MACF,OAAOR,MAAM,CAACK,0BAA0B,CAACE,WAAW,EAAEC,UAAU,CAAC;IACnE,CAAC,CAAC,OAAOC,YAAY,EAAE;MACrBN,QAAQ,CAACM,YAAY,CAAC;MAEtB,OAAOC,SAAS;IAClB;EACF,CAAC,EACD,CAACV,MAAM,CAAC,CACT;EAED,OAAO;IACLK,0BAA0B;IAC1BH;EACF,CAAC;AACH"}
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 and an optional error object.
16
+ * @returns {IFeatureFlagsHookResult} an object containing the `getFeatureFlags` function.
17
17
  */
18
18
  export declare function useFeatureFlags(): IFeatureFlagsHookResult;
@@ -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 and an optional error object.
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
- try {
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","_useError","useFeatureFlags","client","useKameleoon","error","setError","useError","getFeatureFlags","useCallback","unknownError"],"sources":["../src/useFeatureFlags.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { FeatureFlagType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\nimport { useError } from './useError';\nimport { KameleoonError } from './KameleoonError';\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 */\n getFeatureFlags: () => FeatureFlagType[];\n /** An optional error object that may be returned if an error occurs while calling the `getFeatureFlags` function. */\n error: KameleoonError | null;\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 and an optional error object.\n */\nexport function useFeatureFlags(): IFeatureFlagsHookResult {\n const { client } = useKameleoon();\n const { error, setError } = useError();\n\n const getFeatureFlags = useCallback((): FeatureFlagType[] => {\n try {\n return client.getFeatureFlags();\n } catch (unknownError) {\n setError(unknownError);\n\n return [];\n }\n }, [client]);\n\n return {\n getFeatureFlags,\n error,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAcA;AACA;AACA;AACA;AACA;AACO,SAASG,eAAeA,CAAA,EAA4B;EACzD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EACjC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAG,IAAAC,kBAAQ,GAAE;EAEtC,MAAMC,eAAe,GAAG,IAAAC,kBAAW,EAAC,MAAyB;IAC3D,IAAI;MACF,OAAON,MAAM,CAACK,eAAe,EAAE;IACjC,CAAC,CAAC,OAAOE,YAAY,EAAE;MACrBJ,QAAQ,CAACI,YAAY,CAAC;MAEtB,OAAO,EAAE;IACX;EACF,CAAC,EAAE,CAACP,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLK,eAAe;IACfH;EACF,CAAC;AACH"}
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 if the feature rollout rule was of type of `Experimentation`.
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 | undefined} 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.
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 | undefined;
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
- try {
25
- return client.getFeatureFlagVariable(params);
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","_useError","useFeatureVariable","client","useKameleoon","error","setError","useError","getFeatureFlagVariable","useCallback","params","unknownError","undefined"],"sources":["../src/useFeatureVariable.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport {\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n} from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\nimport { KameleoonError } from './KameleoonError';\nimport { useError } from './useError';\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 if the feature rollout rule was of type of `Experimentation`.\n *\n * @param {GetFeatureFlagVariableParamsType} params - `visitorCode`, `featureKey` and `variableKey` parameters to return variable.\n * @return {FeatureVariableResultType | undefined} 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 */\n getFeatureFlagVariable: (\n params: GetFeatureFlagVariableParamsType,\n ) => FeatureVariableResultType | undefined;\n /** An optional error object that may be returned if an error occurs while calling the `getFeatureFlagVariable` function. */\n error: KameleoonError | null;\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 const { error, setError } = useError();\n\n const getFeatureFlagVariable = useCallback(\n (\n params: GetFeatureFlagVariableParamsType,\n ): FeatureVariableResultType | undefined => {\n try {\n return client.getFeatureFlagVariable(params);\n } catch (unknownError) {\n setError(unknownError);\n\n return undefined;\n }\n },\n [client, setError],\n );\n\n return {\n getFeatureFlagVariable,\n error,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAgBA;AACA;AACA;AACA;AACA;AACO,SAASG,kBAAkBA,CAAA,EAA+B;EAC/D,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EACjC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAG,IAAAC,kBAAQ,GAAE;EAEtC,MAAMC,sBAAsB,GAAG,IAAAC,kBAAW,EAEtCC,MAAwC,IACE;IAC1C,IAAI;MACF,OAAOP,MAAM,CAACK,sBAAsB,CAACE,MAAM,CAAC;IAC9C,CAAC,CAAC,OAAOC,YAAY,EAAE;MACrBL,QAAQ,CAACK,YAAY,CAAC;MAEtB,OAAOC,SAAS;IAClB;EACF,CAAC,EACD,CAACT,MAAM,EAAEG,QAAQ,CAAC,CACnB;EAED,OAAO;IACLE,sBAAsB;IACtBH;EACF,CAAC;AACH"}
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"}
@@ -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
  }
@@ -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;AAWA;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"}
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"}
@@ -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 and an optional error object.
14
+ * @returns {IInitializeHookResult} an object containing the asynchronous `initialize` function.
14
15
  */
15
16
  export declare function useInitialize(): IInitializeHookResult;
@@ -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 and an optional error object.
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
- try {
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","_useError","useInitialize","client","useKameleoon","error","setError","useError","initialize","useCallback","unknownError"],"sources":["../src/useInitialize.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\nimport { useError } from './useError';\nimport { KameleoonError } from './KameleoonError';\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 */\n initialize: () => Promise<boolean>;\n /** An optional error object that may be returned if an error occurs while calling the `initialize` function. */\n error: KameleoonError | null;\n}\n\n/**\n * A React Hook that returns asynchronous `initialize` function.\n *\n * @returns {IInitializeHookResult} an object containing the asynchronous `initialize` function and an optional error object.\n */\nexport function useInitialize(): IInitializeHookResult {\n const { client } = useKameleoon();\n const { error, setError } = useError();\n\n const initialize = useCallback(async (): Promise<boolean> => {\n try {\n return await client.initialize();\n } catch (unknownError) {\n setError(unknownError);\n\n return false;\n }\n }, [client]);\n\n return {\n initialize,\n error,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAYA;AACA;AACA;AACA;AACA;AACO,SAASG,aAAaA,CAAA,EAA0B;EACrD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EACjC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAG,IAAAC,kBAAQ,GAAE;EAEtC,MAAMC,UAAU,GAAG,IAAAC,kBAAW,EAAC,YAA8B;IAC3D,IAAI;MACF,OAAO,MAAMN,MAAM,CAACK,UAAU,EAAE;IAClC,CAAC,CAAC,OAAOE,YAAY,EAAE;MACrBJ,QAAQ,CAACI,YAAY,CAAC;MAEtB,OAAO,KAAK;IACd;EACF,CAAC,EAAE,CAACP,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLK,UAAU;IACVH;EACF,CAAC;AACH"}
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"}
@@ -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;
@@ -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 _ProviderError.ProviderError('useKameleoon');
18
+ throw new Error('useKameleoon must be used within a KameleoonProvider');
19
19
  }
20
20
  return {
21
21
  client: context
@@ -1 +1 @@
1
- {"version":3,"file":"useKameleoon.js","names":["_react","require","_KameleoonContext","_ProviderError","useKameleoon","context","useContext","KameleoonContext","ProviderError","client"],"sources":["../src/useKameleoon.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { KameleoonCore } from '@kameleoon/javascript-sdk-core';\nimport { KameleoonContext } from './KameleoonContext';\nimport { ProviderError } from './ProviderError';\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}\n */\nexport function useKameleoon(): IKameleoonHookResult {\n const context = useContext(KameleoonContext);\n\n if (!context) {\n throw new ProviderError('useKameleoon');\n }\n\n return {\n client: context,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAOA;AACA;AACA;AACA;AACA;AACO,SAASG,YAAYA,CAAA,EAAyB;EACnD,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACC,kCAAgB,CAAC;EAE5C,IAAI,CAACF,OAAO,EAAE;IACZ,MAAM,IAAIG,4BAAa,CAAC,cAAc,CAAC;EACzC;EAEA,OAAO;IACLC,MAAM,EAAEJ;EACV,CAAC;AACH"}
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 and an optional error object.
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 and an optional error object.
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\ninterface 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 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 and an optional error object.\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"}
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"}
@@ -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 | undefined>} promise with retrieving data for specific key.
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 | undefined>;
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.
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useRemoteData = useRemoteData;
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 getRemoteData function which retrieves data from Kameleoon server.
12
11
  *
@@ -16,22 +15,11 @@ function useRemoteData() {
16
15
  const {
17
16
  client
18
17
  } = (0, _useKameleoon.useKameleoon)();
19
- const {
20
- error,
21
- setError
22
- } = (0, _useError.useError)();
23
18
  const getRemoteData = (0, _react.useCallback)(async key => {
24
- try {
25
- const remoteData = await client.getRemoteData(key);
26
- return remoteData;
27
- } catch (unknownError) {
28
- setError(unknownError);
29
- return undefined;
30
- }
19
+ return await client.getRemoteData(key);
31
20
  }, [client]);
32
21
  return {
33
- getRemoteData,
34
- error
22
+ getRemoteData
35
23
  };
36
24
  }
37
25
  //# sourceMappingURL=useRemoteData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRemoteData.js","names":["_react","require","_useKameleoon","_useError","useRemoteData","client","useKameleoon","error","setError","useError","getRemoteData","useCallback","key","remoteData","unknownError","undefined"],"sources":["../src/useRemoteData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { JSONType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\nimport { KameleoonError } from './KameleoonError';\nimport { useError } from './useError';\n\nexport interface IRemoteDataHookResult {\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 | undefined>} promise with retrieving data for specific key.\n */\n getRemoteData: (key: string) => Promise<JSONType | undefined>;\n /** An optional error object that may be returned if an error occurs while calling the `getRemoteData` function. */\n error: KameleoonError | null;\n}\n\n/**\n * A React Hook that returns asynchronous getRemoteData function which retrieves data from Kameleoon server.\n *\n * @returns {IRemoteDataHookResult} an object containing the `getRemoteData` function.\n */\nexport function useRemoteData(): IRemoteDataHookResult {\n const { client } = useKameleoon();\n const { error, setError } = useError();\n\n const getRemoteData = useCallback(\n async (key: string): Promise<JSONType | undefined> => {\n try {\n const remoteData = await client.getRemoteData(key);\n\n return remoteData;\n } catch (unknownError) {\n setError(unknownError);\n\n return undefined;\n }\n },\n [client],\n );\n\n return {\n getRemoteData,\n error,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAcA;AACA;AACA;AACA;AACA;AACO,SAASG,aAAaA,CAAA,EAA0B;EACrD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EACjC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAG,IAAAC,kBAAQ,GAAE;EAEtC,MAAMC,aAAa,GAAG,IAAAC,kBAAW,EAC/B,MAAOC,GAAW,IAAoC;IACpD,IAAI;MACF,MAAMC,UAAU,GAAG,MAAMR,MAAM,CAACK,aAAa,CAACE,GAAG,CAAC;MAElD,OAAOC,UAAU;IACnB,CAAC,CAAC,OAAOC,YAAY,EAAE;MACrBN,QAAQ,CAACM,YAAY,CAAC;MAEtB,OAAOC,SAAS;IAClB;EACF,CAAC,EACD,CAACV,MAAM,CAAC,CACT;EAED,OAAO;IACLK,aAAa;IACbH;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"useRemoteData.js","names":["_react","require","_useKameleoon","useRemoteData","client","useKameleoon","getRemoteData","useCallback","key"],"sources":["../src/useRemoteData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { JSONType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IRemoteDataHookResult {\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\n/**\n * A React Hook that returns asynchronous getRemoteData function which retrieves data from Kameleoon server.\n *\n * @returns {IRemoteDataHookResult} an object containing the `getRemoteData` function.\n */\nexport function useRemoteData(): IRemoteDataHookResult {\n const { client } = useKameleoon();\n\n const getRemoteData = useCallback(\n async (key: string): Promise<JSONType> => {\n return await client.getRemoteData(key);\n },\n [client],\n );\n\n return {\n getRemoteData,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAeA;AACA;AACA;AACA;AACA;AACO,SAASE,aAAaA,CAAA,EAA0B;EACrD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,0BAAY,GAAE;EAEjC,MAAMC,aAAa,GAAG,IAAAC,kBAAW,EAC/B,MAAOC,GAAW,IAAwB;IACxC,OAAO,MAAMJ,MAAM,CAACE,aAAa,CAACE,GAAG,CAAC;EACxC,CAAC,EACD,CAACJ,MAAM,CAAC,CACT;EAED,OAAO;IACLE;EACF,CAAC;AACH"}
@@ -1,14 +1,15 @@
1
1
  import { TrackConversionParamsType } from '@kameleoon/javascript-sdk-core';
2
- import { KameleoonError } from './KameleoonError';
3
2
  export interface ITrackConversionHookResult {
4
3
  /**
5
4
  * 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.
6
5
  *
7
6
  * @param {TrackConversionParamsType} params - `visitorCode`, `goalId` and `revenue` parameters for data tracking.
7
+ * @throws `KameleoonError` with one of the following `type` s:
8
+ *
9
+ * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded.
10
+ * - `KameleoonException.StorageWrite` Couldn't update storage data.
8
11
  */
9
12
  trackConversion: (params: TrackConversionParamsType) => void;
10
- /** An optional error object that may be returned if an error occurs while calling the `trackConversion` function. */
11
- error: KameleoonError | null;
12
13
  }
13
14
  /**
14
15
  * A React Hook that returns trackConversion function which tracks conversion.