@kameleoon/react-sdk 3.0.0 → 4.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 (162) hide show
  1. package/README.md +22 -20
  2. package/package.json +2 -2
  3. package/CHANGELOG.md +0 -80
  4. package/dist/Feature.d.ts +0 -11
  5. package/dist/Feature.js +0 -26
  6. package/dist/Feature.js.map +0 -1
  7. package/dist/KameleoonContext.d.ts +0 -3
  8. package/dist/KameleoonContext.js +0 -6
  9. package/dist/KameleoonContext.js.map +0 -1
  10. package/dist/KameleoonError.d.ts +0 -5
  11. package/dist/KameleoonError.js +0 -31
  12. package/dist/KameleoonError.js.map +0 -1
  13. package/dist/KameleoonProvider.d.ts +0 -14
  14. package/dist/KameleoonProvider.js +0 -25
  15. package/dist/KameleoonProvider.js.map +0 -1
  16. package/dist/ProviderError.d.ts +0 -3
  17. package/dist/ProviderError.js +0 -29
  18. package/dist/ProviderError.js.map +0 -1
  19. package/dist/compose.d.ts +0 -8
  20. package/dist/compose.js +0 -58
  21. package/dist/compose.js.map +0 -1
  22. package/dist/constants.d.ts +0 -24
  23. package/dist/constants.js +0 -31
  24. package/dist/constants.js.map +0 -1
  25. package/dist/getKameleoonException.d.ts +0 -2
  26. package/dist/getKameleoonException.js +0 -34
  27. package/dist/getKameleoonException.js.map +0 -1
  28. package/dist/index.d.ts +0 -42
  29. package/dist/index.js +0 -105
  30. package/dist/index.js.map +0 -1
  31. package/dist/kameleoonClient.d.ts +0 -16
  32. package/dist/kameleoonClient.js +0 -17
  33. package/dist/kameleoonClient.js.map +0 -1
  34. package/dist/stories/Form.d.ts +0 -30
  35. package/dist/stories/Form.js +0 -215
  36. package/dist/stories/Form.js.map +0 -1
  37. package/dist/stories/FormHOC.d.ts +0 -2
  38. package/dist/stories/FormHOC.js +0 -41
  39. package/dist/stories/FormHOC.js.map +0 -1
  40. package/dist/stories/FormHook.d.ts +0 -2
  41. package/dist/stories/FormHook.js +0 -74
  42. package/dist/stories/FormHook.js.map +0 -1
  43. package/dist/stories/FormRenderProps.d.ts +0 -3
  44. package/dist/stories/FormRenderProps.js +0 -24
  45. package/dist/stories/FormRenderProps.js.map +0 -1
  46. package/dist/stories/Radio.d.ts +0 -8
  47. package/dist/stories/Radio.js +0 -9
  48. package/dist/stories/Radio.js.map +0 -1
  49. package/dist/stories/constants.d.ts +0 -16
  50. package/dist/stories/constants.js +0 -21
  51. package/dist/stories/constants.js.map +0 -1
  52. package/dist/types.d.ts +0 -37
  53. package/dist/types.js +0 -4
  54. package/dist/types.js.map +0 -1
  55. package/dist/useActivateFeature.d.ts +0 -14
  56. package/dist/useActivateFeature.js +0 -32
  57. package/dist/useActivateFeature.js.map +0 -1
  58. package/dist/useAddData.d.ts +0 -14
  59. package/dist/useAddData.js +0 -49
  60. package/dist/useAddData.js.map +0 -1
  61. package/dist/useBrowser.d.ts +0 -13
  62. package/dist/useBrowser.js +0 -22
  63. package/dist/useBrowser.js.map +0 -1
  64. package/dist/useConversion.d.ts +0 -14
  65. package/dist/useConversion.js +0 -18
  66. package/dist/useConversion.js.map +0 -1
  67. package/dist/useCustomData.d.ts +0 -13
  68. package/dist/useCustomData.js +0 -18
  69. package/dist/useCustomData.js.map +0 -1
  70. package/dist/useError.d.ts +0 -7
  71. package/dist/useError.js +0 -34
  72. package/dist/useError.js.map +0 -1
  73. package/dist/useErrors.d.ts +0 -7
  74. package/dist/useErrors.js +0 -42
  75. package/dist/useErrors.js.map +0 -1
  76. package/dist/useFeature.d.ts +0 -5
  77. package/dist/useFeature.js +0 -104
  78. package/dist/useFeature.js.map +0 -1
  79. package/dist/useFeatureVariable.d.ts +0 -15
  80. package/dist/useFeatureVariable.js +0 -45
  81. package/dist/useFeatureVariable.js.map +0 -1
  82. package/dist/useFlush.d.ts +0 -11
  83. package/dist/useFlush.js +0 -19
  84. package/dist/useFlush.js.map +0 -1
  85. package/dist/useInterest.d.ts +0 -12
  86. package/dist/useInterest.js +0 -16
  87. package/dist/useInterest.js.map +0 -1
  88. package/dist/useKameleoon.d.ts +0 -10
  89. package/dist/useKameleoon.js +0 -20
  90. package/dist/useKameleoon.js.map +0 -1
  91. package/dist/usePageView.d.ts +0 -14
  92. package/dist/usePageView.js +0 -18
  93. package/dist/usePageView.js.map +0 -1
  94. package/dist/useRetrieveDataFromRemoteSource.d.ts +0 -12
  95. package/dist/useRetrieveDataFromRemoteSource.js +0 -79
  96. package/dist/useRetrieveDataFromRemoteSource.js.map +0 -1
  97. package/dist/useRunWhenReady.d.ts +0 -14
  98. package/dist/useRunWhenReady.js +0 -23
  99. package/dist/useRunWhenReady.js.map +0 -1
  100. package/dist/useTrackingConversion.d.ts +0 -13
  101. package/dist/useTrackingConversion.js +0 -19
  102. package/dist/useTrackingConversion.js.map +0 -1
  103. package/dist/useTriggerExperiment.d.ts +0 -17
  104. package/dist/useTriggerExperiment.js +0 -32
  105. package/dist/useTriggerExperiment.js.map +0 -1
  106. package/dist/useVariationAssociatedData.d.ts +0 -16
  107. package/dist/useVariationAssociatedData.js +0 -30
  108. package/dist/useVariationAssociatedData.js.map +0 -1
  109. package/dist/useVisitorCode.d.ts +0 -12
  110. package/dist/useVisitorCode.js +0 -19
  111. package/dist/useVisitorCode.js.map +0 -1
  112. package/dist/withActivateFeature.d.ts +0 -17
  113. package/dist/withActivateFeature.js +0 -28
  114. package/dist/withActivateFeature.js.map +0 -1
  115. package/dist/withAddData.d.ts +0 -16
  116. package/dist/withAddData.js +0 -65
  117. package/dist/withAddData.js.map +0 -1
  118. package/dist/withBrowser.d.ts +0 -16
  119. package/dist/withBrowser.js +0 -35
  120. package/dist/withBrowser.js.map +0 -1
  121. package/dist/withConversion.d.ts +0 -17
  122. package/dist/withConversion.js +0 -31
  123. package/dist/withConversion.js.map +0 -1
  124. package/dist/withCustomData.d.ts +0 -16
  125. package/dist/withCustomData.js +0 -31
  126. package/dist/withCustomData.js.map +0 -1
  127. package/dist/withFeature.d.ts +0 -6
  128. package/dist/withFeature.js +0 -31
  129. package/dist/withFeature.js.map +0 -1
  130. package/dist/withFeatureVariable.d.ts +0 -17
  131. package/dist/withFeatureVariable.js +0 -28
  132. package/dist/withFeatureVariable.js.map +0 -1
  133. package/dist/withFlush.d.ts +0 -14
  134. package/dist/withFlush.js +0 -36
  135. package/dist/withFlush.js.map +0 -1
  136. package/dist/withInterest.d.ts +0 -15
  137. package/dist/withInterest.js +0 -31
  138. package/dist/withInterest.js.map +0 -1
  139. package/dist/withKameleoon.d.ts +0 -13
  140. package/dist/withKameleoon.js +0 -33
  141. package/dist/withKameleoon.js.map +0 -1
  142. package/dist/withPageView.d.ts +0 -17
  143. package/dist/withPageView.js +0 -31
  144. package/dist/withPageView.js.map +0 -1
  145. package/dist/withRetrieveDataFromRemoteSource.d.ts +0 -14
  146. package/dist/withRetrieveDataFromRemoteSource.js +0 -28
  147. package/dist/withRetrieveDataFromRemoteSource.js.map +0 -1
  148. package/dist/withRunWhenReady.d.ts +0 -16
  149. package/dist/withRunWhenReady.js +0 -28
  150. package/dist/withRunWhenReady.js.map +0 -1
  151. package/dist/withTrackingConversion.d.ts +0 -16
  152. package/dist/withTrackingConversion.js +0 -36
  153. package/dist/withTrackingConversion.js.map +0 -1
  154. package/dist/withTriggerExperiment.d.ts +0 -19
  155. package/dist/withTriggerExperiment.js +0 -30
  156. package/dist/withTriggerExperiment.js.map +0 -1
  157. package/dist/withVariationAssociatedData.d.ts +0 -18
  158. package/dist/withVariationAssociatedData.js +0 -30
  159. package/dist/withVariationAssociatedData.js.map +0 -1
  160. package/dist/withVisitorCode.d.ts +0 -15
  161. package/dist/withVisitorCode.js +0 -36
  162. package/dist/withVisitorCode.js.map +0 -1
package/dist/useFlush.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useFlush = void 0;
4
- var react_1 = require("react");
5
- var useKameleoon_1 = require("./useKameleoon");
6
- /**
7
- * A React Hook that returns callback function which allows to flush data to servers
8
- */
9
- function useFlush() {
10
- var client = (0, useKameleoon_1.useKameleoon)().client;
11
- var flush = (0, react_1.useCallback)(function (visitorCode) {
12
- client.flush(visitorCode);
13
- }, [client]);
14
- return {
15
- flush: flush,
16
- };
17
- }
18
- exports.useFlush = useFlush;
19
- //# sourceMappingURL=useFlush.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFlush.js","sourceRoot":"","sources":["../src/useFlush.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAS9C;;GAEG;AACH,SAAgB,QAAQ;IACd,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,KAAK,GAAG,IAAA,mBAAW,EACvB,UAAC,WAAmB;QAClB,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC5B,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,KAAK,OAAA;KACN,CAAC;AACJ,CAAC;AAbD,4BAaC"}
@@ -1,12 +0,0 @@
1
- import { Interest } from 'kameleoon-client-javascript/dist/data';
2
- interface InterestHookResult {
3
- /**
4
- * @param index - index of interest
5
- */
6
- addInterest: (index: number) => Interest;
7
- }
8
- /**
9
- * A React Hook that returns callback function which adds interest
10
- */
11
- export declare function useInterest(): InterestHookResult;
12
- export {};
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useInterest = void 0;
4
- var react_1 = require("react");
5
- var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
6
- /**
7
- * A React Hook that returns callback function which adds interest
8
- */
9
- function useInterest() {
10
- var addInterest = (0, react_1.useCallback)(function (index) { return new kameleoon_client_javascript_1.KameleoonData.Interest(index); }, []);
11
- return {
12
- addInterest: addInterest,
13
- };
14
- }
15
- exports.useInterest = useInterest;
16
- //# sourceMappingURL=useInterest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useInterest.js","sourceRoot":"","sources":["../src/useInterest.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,2EAA4D;AAU5D;;GAEG;AACH,SAAgB,WAAW;IACzB,IAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,UAAC,KAAa,IAAe,OAAA,IAAI,2CAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAjC,CAAiC,EAC9D,EAAE,CACH,CAAC;IAEF,OAAO;QACL,WAAW,aAAA;KACZ,CAAC;AACJ,CAAC;AATD,kCASC"}
@@ -1,10 +0,0 @@
1
- import { KameleoonClient } from 'kameleoon-client-javascript';
2
- interface KameleoonHookResult {
3
- /** An instance of KameleoonClient */
4
- client: KameleoonClient;
5
- }
6
- /**
7
- * A React Hook that validates if context is used within a KameleoonProvider and returns it
8
- */
9
- export declare function useKameleoon(): KameleoonHookResult;
10
- export {};
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useKameleoon = void 0;
4
- var react_1 = require("react");
5
- var KameleoonContext_1 = require("./KameleoonContext");
6
- var ProviderError_1 = require("./ProviderError");
7
- /**
8
- * A React Hook that validates if context is used within a KameleoonProvider and returns it
9
- */
10
- function useKameleoon() {
11
- var context = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
12
- if (!context) {
13
- throw new ProviderError_1.ProviderError('useKameleoon');
14
- }
15
- return {
16
- client: context,
17
- };
18
- }
19
- exports.useKameleoon = useKameleoon;
20
- //# sourceMappingURL=useKameleoon.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useKameleoon.js","sourceRoot":"","sources":["../src/useKameleoon.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAEnC,uDAAsD;AACtD,iDAAgD;AAOhD;;GAEG;AACH,SAAgB,YAAY;IAC1B,IAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;IAE7C,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,6BAAa,CAAC,cAAc,CAAC,CAAC;KACzC;IAED,OAAO;QACL,MAAM,EAAE,OAAO;KAChB,CAAC;AACJ,CAAC;AAVD,oCAUC"}
@@ -1,14 +0,0 @@
1
- import { PageView } from 'kameleoon-client-javascript/dist/data';
2
- interface PageViewHookResult {
3
- /**
4
- * @param url - URL of the page viewed
5
- * @param title - title of the page viewed
6
- * @param referrer - referrer of the page viewed
7
- */
8
- addPageView: (url: string, title: string, referrer?: number) => PageView;
9
- }
10
- /**
11
- * A React Hook that returns callback function which adds page view
12
- */
13
- export declare function usePageView(): PageViewHookResult;
14
- export {};
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.usePageView = void 0;
4
- var react_1 = require("react");
5
- var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
6
- /**
7
- * A React Hook that returns callback function which adds page view
8
- */
9
- function usePageView() {
10
- var addPageView = (0, react_1.useCallback)(function (url, title, referrer) {
11
- return new kameleoon_client_javascript_1.KameleoonData.PageView(url, title, referrer);
12
- }, []);
13
- return {
14
- addPageView: addPageView,
15
- };
16
- }
17
- exports.usePageView = usePageView;
18
- //# sourceMappingURL=usePageView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePageView.js","sourceRoot":"","sources":["../src/usePageView.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,2EAA4D;AAY5D;;GAEG;AACH,SAAgB,WAAW;IACzB,IAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,UAAC,GAAW,EAAE,KAAa,EAAE,QAAiB;QAC5C,OAAA,IAAI,2CAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC;IAAhD,CAAgD,EAClD,EAAE,CACH,CAAC;IAEF,OAAO;QACL,WAAW,aAAA;KACZ,CAAC;AACJ,CAAC;AAVD,kCAUC"}
@@ -1,12 +0,0 @@
1
- import { RemoteSourceResultType } from './types';
2
- interface RetrieveDataFromRemoteSourceHookResult {
3
- /**
4
- * @param key - unique key for data defined for Kameleoon Data API
5
- */
6
- retrieveDataFromRemoteSource: (key: string) => Promise<RemoteSourceResultType>;
7
- }
8
- /**
9
- * A React Hook that returns asynchronous callback function which retrieves data from Kameleoon Data API
10
- */
11
- export declare function useRetrieveDataFromRemoteSource(): RetrieveDataFromRemoteSourceHookResult;
12
- export {};
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.useRetrieveDataFromRemoteSource = void 0;
40
- var react_1 = require("react");
41
- var useKameleoon_1 = require("./useKameleoon");
42
- var ProviderError_1 = require("./ProviderError");
43
- var KameleoonError_1 = require("./KameleoonError");
44
- var constants_1 = require("./constants");
45
- /**
46
- * A React Hook that returns asynchronous callback function which retrieves data from Kameleoon Data API
47
- */
48
- function useRetrieveDataFromRemoteSource() {
49
- var _this = this;
50
- var client = (0, useKameleoon_1.useKameleoon)().client;
51
- var isObjectEmpty = (0, react_1.useCallback)(function (object) {
52
- return (object &&
53
- Object.keys(object).length === 0 &&
54
- Object.getPrototypeOf(object) === Object.prototype);
55
- }, []);
56
- var retrieveDataFromRemoteSource = (0, react_1.useCallback)(function (key) { return __awaiter(_this, void 0, void 0, function () {
57
- var resultData, error;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0: return [4 /*yield*/, client.retrieveDataFromRemoteSource(key)];
61
- case 1:
62
- resultData = (_a.sent());
63
- if (isObjectEmpty(resultData)) {
64
- error = new KameleoonError_1.KameleoonError(constants_1.KameleoonException.NoDataWasRetrievedFromRemoteServer);
65
- return [2 /*return*/, { data: null, error: error }];
66
- }
67
- return [2 /*return*/, { data: resultData, error: null }];
68
- }
69
- });
70
- }); }, [client, isObjectEmpty]);
71
- if (!client) {
72
- throw new ProviderError_1.ProviderError('useKameleoon');
73
- }
74
- return {
75
- retrieveDataFromRemoteSource: retrieveDataFromRemoteSource,
76
- };
77
- }
78
- exports.useRetrieveDataFromRemoteSource = useRetrieveDataFromRemoteSource;
79
- //# sourceMappingURL=useRetrieveDataFromRemoteSource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useRetrieveDataFromRemoteSource.js","sourceRoot":"","sources":["../src/useRetrieveDataFromRemoteSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAoC;AACpC,+CAA8C;AAC9C,iDAAgD;AAEhD,mDAAkD;AAClD,yCAAiD;AAWjD;;GAEG;AACH,SAAgB,+BAA+B;IAA/C,iBAqCC;IApCS,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,aAAa,GAAG,IAAA,mBAAW,EAAC,UAAC,MAA4B;QAC7D,OAAO,CACL,MAAM;YACN,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YAChC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,SAAS,CACnD,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAM,4BAA4B,GAAG,IAAA,mBAAW,EAC9C,UAAO,GAAW;;;;wBACI,qBAAM,MAAM,CAAC,4BAA4B,CAC3D,GAAG,CACJ,EAAA;;oBAFK,UAAU,GAAG,CAAC,SAEnB,CAAyB;oBAE1B,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE;wBACvB,KAAK,GAAG,IAAI,+BAAc,CAC9B,8BAAkB,CAAC,kCAAkC,CACtD,CAAC;wBAEF,sBAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,OAAA,EAAE,EAAC;qBAC9B;oBAED,sBAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,EAAC;;;SAC1C,EACD,CAAC,MAAM,EAAE,aAAa,CAAC,CACxB,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,6BAAa,CAAC,cAAc,CAAC,CAAC;KACzC;IAED,OAAO;QACL,4BAA4B,8BAAA;KAC7B,CAAC;AACJ,CAAC;AArCD,0EAqCC"}
@@ -1,14 +0,0 @@
1
- interface RunWhenReadyHookResult {
2
- /**
3
- * @param successCallback - callback which will be executed on successful client initialization
4
- * @param errorCallback - callback which will be executed if client wasn't able to initialize during the timeout
5
- * @param timeout - timeout which is given to perform HTTP call for initialization in ms (by default: 2 seconds)
6
- */
7
- runWhenReady: (successCallback: () => void, errorCallback: () => void, timeout?: number) => void;
8
- }
9
- /**
10
- * A React Hook that returns callback function which makes sure that
11
- * Kameleoon Client will be initialized properly using HTTP call within the specified timeout
12
- */
13
- export declare function useRunWhenReady(): RunWhenReadyHookResult;
14
- export {};
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useRunWhenReady = void 0;
4
- var react_1 = require("react");
5
- var useKameleoon_1 = require("./useKameleoon");
6
- var ProviderError_1 = require("./ProviderError");
7
- /**
8
- * A React Hook that returns callback function which makes sure that
9
- * Kameleoon Client will be initialized properly using HTTP call within the specified timeout
10
- */
11
- function useRunWhenReady() {
12
- var client = (0, useKameleoon_1.useKameleoon)().client;
13
- var DEFAULT_TIMEOUT = 2000;
14
- var runWhenReady = (0, react_1.useCallback)(function (successCallback, errorCallback, timeout) {
15
- client.runWhenReady(successCallback, errorCallback, timeout !== null && timeout !== void 0 ? timeout : DEFAULT_TIMEOUT);
16
- }, [client]);
17
- if (!client) {
18
- throw new ProviderError_1.ProviderError('useRunWhenReady');
19
- }
20
- return { runWhenReady: runWhenReady };
21
- }
22
- exports.useRunWhenReady = useRunWhenReady;
23
- //# sourceMappingURL=useRunWhenReady.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useRunWhenReady.js","sourceRoot":"","sources":["../src/useRunWhenReady.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAC9C,iDAAgD;AAehD;;;GAGG;AACH,SAAgB,eAAe;IACrB,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAClC,IAAM,eAAe,GAAG,IAAI,CAAC;IAE7B,IAAM,YAAY,GAAG,IAAA,mBAAW,EAC9B,UACE,eAA2B,EAC3B,aAAyB,EACzB,OAAgB;QAEhB,MAAM,CAAC,YAAY,CACjB,eAAe,EACf,aAAa,EACb,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,eAAe,CAC3B,CAAC;IACJ,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,6BAAa,CAAC,iBAAiB,CAAC,CAAC;KAC5C;IAED,OAAO,EAAE,YAAY,cAAA,EAAE,CAAC;AAC1B,CAAC;AAxBD,0CAwBC"}
@@ -1,13 +0,0 @@
1
- interface TrackingConversionHookResult {
2
- /**
3
- * @param visitorCode - unique identifier of the user
4
- * @param goalId - unique identifier of the goal
5
- * @param revenue - revenue of the conversion
6
- */
7
- trackConversion: (visitorCode: string, goalId: number, revenue?: number) => void;
8
- }
9
- /**
10
- * A React Hook that returns callback function which tracks conversion
11
- */
12
- export declare function useTrackingConversion(): TrackingConversionHookResult;
13
- export {};
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useTrackingConversion = void 0;
4
- var react_1 = require("react");
5
- var useKameleoon_1 = require("./useKameleoon");
6
- /**
7
- * A React Hook that returns callback function which tracks conversion
8
- */
9
- function useTrackingConversion() {
10
- var client = (0, useKameleoon_1.useKameleoon)().client;
11
- var trackConversion = (0, react_1.useCallback)(function (visitorCode, goalId, revenue) {
12
- client.trackConversion(visitorCode, goalId, revenue);
13
- }, [client]);
14
- return {
15
- trackConversion: trackConversion,
16
- };
17
- }
18
- exports.useTrackingConversion = useTrackingConversion;
19
- //# sourceMappingURL=useTrackingConversion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTrackingConversion.js","sourceRoot":"","sources":["../src/useTrackingConversion.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAe9C;;GAEG;AACH,SAAgB,qBAAqB;IAC3B,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,eAAe,GAAG,IAAA,mBAAW,EACjC,UAAC,WAAmB,EAAE,MAAc,EAAE,OAAgB;QACpD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;KAChB,CAAC;AACJ,CAAC;AAbD,sDAaC"}
@@ -1,17 +0,0 @@
1
- import { KameleoonError } from './KameleoonError';
2
- interface IGetVariationIdHookResult {
3
- /**
4
- * @param visitorCode - unique identifier of the user
5
- * @param experimentId - unique identifier of the experiment you want to expose to a user
6
- */
7
- getVariationId: (visitorCode: string, experimentId: number) => number;
8
- error: KameleoonError | null;
9
- }
10
- /**
11
- * A React Hook that returns callback function which triggers experiment.
12
- * If such a user has never been associated with any variation, the SDK returns a randomly selected variation.
13
- * If a user with a given visitorCode is already registered with a variation,
14
- * it will detect the previously registered variation and return the variationID
15
- */
16
- export declare function useTriggerExperiment(): IGetVariationIdHookResult;
17
- export {};
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useTriggerExperiment = void 0;
4
- var react_1 = require("react");
5
- var useKameleoon_1 = require("./useKameleoon");
6
- var useError_1 = require("./useError");
7
- /**
8
- * A React Hook that returns callback function which triggers experiment.
9
- * If such a user has never been associated with any variation, the SDK returns a randomly selected variation.
10
- * If a user with a given visitorCode is already registered with a variation,
11
- * it will detect the previously registered variation and return the variationID
12
- */
13
- function useTriggerExperiment() {
14
- var _a = (0, useError_1.useError)(), error = _a.error, setError = _a.setError;
15
- var client = (0, useKameleoon_1.useKameleoon)().client;
16
- var DEFAULT_VARIATION_ID = 0;
17
- var getVariationId = (0, react_1.useCallback)(function (visitorCode, experimentId) {
18
- try {
19
- return client.triggerExperiment(visitorCode, experimentId);
20
- }
21
- catch (unknownError) {
22
- setError(unknownError);
23
- return DEFAULT_VARIATION_ID;
24
- }
25
- }, [client, setError]);
26
- return {
27
- getVariationId: getVariationId,
28
- error: error,
29
- };
30
- }
31
- exports.useTriggerExperiment = useTriggerExperiment;
32
- //# sourceMappingURL=useTriggerExperiment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTriggerExperiment.js","sourceRoot":"","sources":["../src/useTriggerExperiment.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAE9C,uCAAsC;AAWtC;;;;;GAKG;AACH,SAAgB,oBAAoB;IAC5B,IAAA,KAAsB,IAAA,mBAAQ,GAAE,EAA9B,KAAK,WAAA,EAAE,QAAQ,cAAe,CAAC;IAC/B,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAClC,IAAM,oBAAoB,GAAG,CAAC,CAAC;IAE/B,IAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,UAAC,WAAmB,EAAE,YAAoB;QACxC,IAAI;YACF,OAAO,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;SAC5D;QAAC,OAAO,YAAY,EAAE;YACrB,QAAQ,CAAC,YAAY,CAAC,CAAC;YAEvB,OAAO,oBAAoB,CAAC;SAC7B;IACH,CAAC,EACD,CAAC,MAAM,EAAE,QAAQ,CAAC,CACnB,CAAC;IAEF,OAAO;QACL,cAAc,gBAAA;QACd,KAAK,OAAA;KACN,CAAC;AACJ,CAAC;AAtBD,oDAsBC"}
@@ -1,16 +0,0 @@
1
- import { KameleoonError } from './KameleoonError';
2
- import { VariationAssociatedDataType } from './types';
3
- interface VariationAssociatedDataHookResult {
4
- /**
5
- * @param variationId - unique identifier of the variation you want to obtain associated data for
6
- */
7
- getVariationAssociatedData: (variationId: number) => VariationAssociatedDataType;
8
- error: KameleoonError | null;
9
- }
10
- /**
11
- * A React Hook that returns callback function which retrieves JSON data associated with a variation.
12
- * The JSON data usually represents some metadata of the variation,
13
- * and can be configured on our web application interface or via our Automation API.
14
- */
15
- export declare function useVariationAssociatedData(): VariationAssociatedDataHookResult;
16
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useVariationAssociatedData = void 0;
4
- var react_1 = require("react");
5
- var useKameleoon_1 = require("./useKameleoon");
6
- var useError_1 = require("./useError");
7
- /**
8
- * A React Hook that returns callback function which retrieves JSON data associated with a variation.
9
- * The JSON data usually represents some metadata of the variation,
10
- * and can be configured on our web application interface or via our Automation API.
11
- */
12
- function useVariationAssociatedData() {
13
- var client = (0, useKameleoon_1.useKameleoon)().client;
14
- var _a = (0, useError_1.useError)(), error = _a.error, setError = _a.setError;
15
- var getVariationAssociatedData = (0, react_1.useCallback)(function (variationId) {
16
- try {
17
- return client.obtainVariationAssociatedData(variationId);
18
- }
19
- catch (unknownError) {
20
- setError(unknownError);
21
- return null;
22
- }
23
- }, [client, setError]);
24
- return {
25
- getVariationAssociatedData: getVariationAssociatedData,
26
- error: error,
27
- };
28
- }
29
- exports.useVariationAssociatedData = useVariationAssociatedData;
30
- //# sourceMappingURL=useVariationAssociatedData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useVariationAssociatedData.js","sourceRoot":"","sources":["../src/useVariationAssociatedData.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAG9C,uCAAsC;AAYtC;;;;GAIG;AACH,SAAgB,0BAA0B;IAChC,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAC5B,IAAA,KAAsB,IAAA,mBAAQ,GAAE,EAA9B,KAAK,WAAA,EAAE,QAAQ,cAAe,CAAC;IAEvC,IAAM,0BAA0B,GAAG,IAAA,mBAAW,EAC5C,UAAC,WAAmB;QAClB,IAAI;YACF,OAAO,MAAM,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;SAC1D;QAAC,OAAO,YAAY,EAAE;YACrB,QAAQ,CAAC,YAAY,CAAC,CAAC;YAEvB,OAAO,IAAI,CAAC;SACb;IACH,CAAC,EACD,CAAC,MAAM,EAAE,QAAQ,CAAC,CACnB,CAAC;IAEF,OAAO;QACL,0BAA0B,4BAAA;QAC1B,KAAK,OAAA;KACN,CAAC;AACJ,CAAC;AArBD,gEAqBC"}
@@ -1,12 +0,0 @@
1
- interface VisitorCodeHookResult {
2
- /**
3
- * @param topLevelDomain - current top level domain for the concerned site
4
- * @param defaultVisitorCode - this parameter will be used as the visitorCode
5
- */
6
- getVisitorCode: (topLevelDomain: string, defaultVisitorCode?: string) => string;
7
- }
8
- /**
9
- * A React Hook that returns callback function which obtains the Kameleoon visitorCode for the current visitor
10
- */
11
- export declare function useVisitorCode(): VisitorCodeHookResult;
12
- export {};
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useVisitorCode = void 0;
4
- var react_1 = require("react");
5
- var useKameleoon_1 = require("./useKameleoon");
6
- /**
7
- * A React Hook that returns callback function which obtains the Kameleoon visitorCode for the current visitor
8
- */
9
- function useVisitorCode() {
10
- var client = (0, useKameleoon_1.useKameleoon)().client;
11
- var getVisitorCode = (0, react_1.useCallback)(function (topLevelDomain, defaultVisitorCode) {
12
- return client.obtainVisitorCode(topLevelDomain, defaultVisitorCode);
13
- }, [client]);
14
- return {
15
- getVisitorCode: getVisitorCode,
16
- };
17
- }
18
- exports.useVisitorCode = useVisitorCode;
19
- //# sourceMappingURL=useVisitorCode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useVisitorCode.js","sourceRoot":"","sources":["../src/useVisitorCode.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAa9C;;GAEG;AACH,SAAgB,cAAc;IACpB,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,UAAC,cAAsB,EAAE,kBAA2B;QAClD,OAAA,MAAM,CAAC,iBAAiB,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAA5D,CAA4D,EAC9D,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,cAAc,gBAAA;KACf,CAAC;AACJ,CAAC;AAZD,wCAYC"}
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import { UnknownPropsType, Without } from './types';
3
- import { KameleoonError } from './KameleoonError';
4
- interface IWithHasFeature {
5
- /**
6
- * @param visitorCode - unique identifier of the user
7
- * @param featureKey - unique identifier or key of the feature you want to expose to a user
8
- */
9
- hasFeature: (visitorCode: string, featureKey: string | number) => boolean;
10
- activateFeatureError: KameleoonError | null;
11
- }
12
- /**
13
- * A React HOC that gives a wrapped component access to callback
14
- * function which activates a feature toggle
15
- */
16
- export declare function withActivateFeature<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithHasFeature>>;
17
- export {};
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.withActivateFeature = void 0;
15
- var jsx_runtime_1 = require("react/jsx-runtime");
16
- var useActivateFeature_1 = require("./useActivateFeature");
17
- /**
18
- * A React HOC that gives a wrapped component access to callback
19
- * function which activates a feature toggle
20
- */
21
- function withActivateFeature(Component) {
22
- return function WrappedComponent(props) {
23
- var _a = (0, useActivateFeature_1.useActivateFeature)(), hasFeature = _a.hasFeature, activateFeatureError = _a.error;
24
- return ((0, jsx_runtime_1.jsx)(Component, __assign({ hasFeature: hasFeature, activateFeatureError: activateFeatureError }, props), void 0));
25
- };
26
- }
27
- exports.withActivateFeature = withActivateFeature;
28
- //# sourceMappingURL=withActivateFeature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withActivateFeature.js","sourceRoot":"","sources":["../src/withActivateFeature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,2DAA0D;AAY1D;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACrC,IAAA,KAA8C,IAAA,uCAAkB,GAAE,EAAhE,UAAU,gBAAA,EAAS,oBAAoB,WAAyB,CAAC;QAEzE,OAAO,CACL,uBAAC,SAAS,aACR,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,oBAAoB,IACrC,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAdD,kDAcC"}
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import { DataInterface as IData } from 'kameleoon-client-javascript/dist/interfaces/interfaces';
3
- import { UnknownPropsType, Without } from './types';
4
- interface IWithAddData {
5
- /**
6
- * @param visitorCode - unique identifier of the user
7
- * @param dataTypes - custom data types which may be passed separated by a comma
8
- */
9
- addData: (visitorCode: string, ...dataTypes: IData[]) => void;
10
- }
11
- /**
12
- * A React HOC that gives a wrapped component access to callback function
13
- * which adds various data to associate this data with the current user
14
- */
15
- export declare function withAddData<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithAddData>>;
16
- export {};
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __read = (this && this.__read) || function (o, n) {
14
- var m = typeof Symbol === "function" && o[Symbol.iterator];
15
- if (!m) return o;
16
- var i = m.call(o), r, ar = [], e;
17
- try {
18
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
- }
20
- catch (error) { e = { error: error }; }
21
- finally {
22
- try {
23
- if (r && !r.done && (m = i["return"])) m.call(i);
24
- }
25
- finally { if (e) throw e.error; }
26
- }
27
- return ar;
28
- };
29
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
30
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31
- if (ar || !(i in from)) {
32
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33
- ar[i] = from[i];
34
- }
35
- }
36
- return to.concat(ar || Array.prototype.slice.call(from));
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.withAddData = void 0;
40
- var jsx_runtime_1 = require("react/jsx-runtime");
41
- var react_1 = require("react");
42
- var KameleoonContext_1 = require("./KameleoonContext");
43
- var ProviderError_1 = require("./ProviderError");
44
- /**
45
- * A React HOC that gives a wrapped component access to callback function
46
- * which adds various data to associate this data with the current user
47
- */
48
- function withAddData(Component) {
49
- return function WrappedComponent(props) {
50
- var client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
51
- var addData = (0, react_1.useCallback)(function (visitorCode) {
52
- var dataTypes = [];
53
- for (var _i = 1; _i < arguments.length; _i++) {
54
- dataTypes[_i - 1] = arguments[_i];
55
- }
56
- if (!client) {
57
- throw new ProviderError_1.ProviderError('withAddData');
58
- }
59
- return client.addData.apply(client, __spreadArray([visitorCode], __read(dataTypes), false));
60
- }, [client]);
61
- return (0, jsx_runtime_1.jsx)(Component, __assign({ addData: addData }, props), void 0);
62
- };
63
- }
64
- exports.withAddData = withAddData;
65
- //# sourceMappingURL=withAddData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withAddData.js","sourceRoot":"","sources":["../src/withAddData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAuD;AAGvD,uDAAsD;AACtD,iDAAgD;AAUhD;;;GAGG;AACH,SAAgB,WAAW,CACzB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,OAAO,GAAG,IAAA,mBAAW,EACzB,UAAC,WAAmB;YAAE,mBAAqB;iBAArB,UAAqB,EAArB,qBAAqB,EAArB,IAAqB;gBAArB,kCAAqB;;YACzC,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,aAAa,CAAC,CAAC;aACxC;YAED,OAAO,MAAM,CAAC,OAAO,OAAd,MAAM,iBAAS,WAAW,UAAK,SAAS,WAAE;QACnD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,OAAO,EAAE,OAAO,IAAO,KAAe,UAAI,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AAnBD,kCAmBC"}
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import { Browser as IBrowser } from 'kameleoon-client-javascript/dist/data';
3
- import { Browser } from './constants';
4
- import { UnknownPropsType, Without } from './types';
5
- interface IWithBrowser {
6
- /**
7
- * @param browser - browser types: CHROME, INTERNET_EXPLORER, FIREFOX, SAFARI, OPERA, OTHER
8
- */
9
- addBrowser: (browser: Browser) => IBrowser;
10
- }
11
- /**
12
- * A React HOC that gives a wrapped component access to callback function
13
- * which adds browser type
14
- */
15
- export declare function withBrowser<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithBrowser>>;
16
- export {};