@kameleoon/react-sdk 4.0.0 → 4.0.1

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 (160) hide show
  1. package/dist/Feature.d.ts +11 -0
  2. package/dist/Feature.js +26 -0
  3. package/dist/Feature.js.map +1 -0
  4. package/dist/KameleoonContext.d.ts +3 -0
  5. package/dist/KameleoonContext.js +6 -0
  6. package/dist/KameleoonContext.js.map +1 -0
  7. package/dist/KameleoonError.d.ts +5 -0
  8. package/dist/KameleoonError.js +31 -0
  9. package/dist/KameleoonError.js.map +1 -0
  10. package/dist/KameleoonProvider.d.ts +14 -0
  11. package/dist/KameleoonProvider.js +25 -0
  12. package/dist/KameleoonProvider.js.map +1 -0
  13. package/dist/ProviderError.d.ts +3 -0
  14. package/dist/ProviderError.js +29 -0
  15. package/dist/ProviderError.js.map +1 -0
  16. package/dist/compose.d.ts +8 -0
  17. package/dist/compose.js +58 -0
  18. package/dist/compose.js.map +1 -0
  19. package/dist/constants.d.ts +24 -0
  20. package/dist/constants.js +31 -0
  21. package/dist/constants.js.map +1 -0
  22. package/dist/getKameleoonException.d.ts +2 -0
  23. package/dist/getKameleoonException.js +34 -0
  24. package/dist/getKameleoonException.js.map +1 -0
  25. package/dist/index.d.ts +42 -0
  26. package/dist/index.js +106 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/kameleoonClient.d.ts +16 -0
  29. package/dist/kameleoonClient.js +17 -0
  30. package/dist/kameleoonClient.js.map +1 -0
  31. package/dist/stories/Form.d.ts +30 -0
  32. package/dist/stories/Form.js +215 -0
  33. package/dist/stories/Form.js.map +1 -0
  34. package/dist/stories/FormHOC.d.ts +2 -0
  35. package/dist/stories/FormHOC.js +41 -0
  36. package/dist/stories/FormHOC.js.map +1 -0
  37. package/dist/stories/FormHook.d.ts +2 -0
  38. package/dist/stories/FormHook.js +74 -0
  39. package/dist/stories/FormHook.js.map +1 -0
  40. package/dist/stories/FormRenderProps.d.ts +3 -0
  41. package/dist/stories/FormRenderProps.js +24 -0
  42. package/dist/stories/FormRenderProps.js.map +1 -0
  43. package/dist/stories/Radio.d.ts +8 -0
  44. package/dist/stories/Radio.js +9 -0
  45. package/dist/stories/Radio.js.map +1 -0
  46. package/dist/stories/constants.d.ts +16 -0
  47. package/dist/stories/constants.js +21 -0
  48. package/dist/stories/constants.js.map +1 -0
  49. package/dist/types.d.ts +37 -0
  50. package/dist/types.js +4 -0
  51. package/dist/types.js.map +1 -0
  52. package/dist/useActivateFeature.d.ts +14 -0
  53. package/dist/useActivateFeature.js +35 -0
  54. package/dist/useActivateFeature.js.map +1 -0
  55. package/dist/useAddData.d.ts +14 -0
  56. package/dist/useAddData.js +49 -0
  57. package/dist/useAddData.js.map +1 -0
  58. package/dist/useBrowser.d.ts +13 -0
  59. package/dist/useBrowser.js +22 -0
  60. package/dist/useBrowser.js.map +1 -0
  61. package/dist/useConversion.d.ts +14 -0
  62. package/dist/useConversion.js +18 -0
  63. package/dist/useConversion.js.map +1 -0
  64. package/dist/useCustomData.d.ts +13 -0
  65. package/dist/useCustomData.js +18 -0
  66. package/dist/useCustomData.js.map +1 -0
  67. package/dist/useDevice.d.ts +12 -0
  68. package/dist/useDevice.js +16 -0
  69. package/dist/useDevice.js.map +1 -0
  70. package/dist/useError.d.ts +7 -0
  71. package/dist/useError.js +34 -0
  72. package/dist/useError.js.map +1 -0
  73. package/dist/useErrors.d.ts +7 -0
  74. package/dist/useErrors.js +42 -0
  75. package/dist/useErrors.js.map +1 -0
  76. package/dist/useFeature.d.ts +5 -0
  77. package/dist/useFeature.js +104 -0
  78. package/dist/useFeature.js.map +1 -0
  79. package/dist/useFeatureVariable.d.ts +15 -0
  80. package/dist/useFeatureVariable.js +41 -0
  81. package/dist/useFeatureVariable.js.map +1 -0
  82. package/dist/useFlush.d.ts +11 -0
  83. package/dist/useFlush.js +19 -0
  84. package/dist/useFlush.js.map +1 -0
  85. package/dist/useKameleoon.d.ts +10 -0
  86. package/dist/useKameleoon.js +20 -0
  87. package/dist/useKameleoon.js.map +1 -0
  88. package/dist/usePageView.d.ts +14 -0
  89. package/dist/usePageView.js +18 -0
  90. package/dist/usePageView.js.map +1 -0
  91. package/dist/useRetrieveDataFromRemoteSource.d.ts +12 -0
  92. package/dist/useRetrieveDataFromRemoteSource.js +79 -0
  93. package/dist/useRetrieveDataFromRemoteSource.js.map +1 -0
  94. package/dist/useRunWhenReady.d.ts +14 -0
  95. package/dist/useRunWhenReady.js +23 -0
  96. package/dist/useRunWhenReady.js.map +1 -0
  97. package/dist/useTrackingConversion.d.ts +13 -0
  98. package/dist/useTrackingConversion.js +19 -0
  99. package/dist/useTrackingConversion.js.map +1 -0
  100. package/dist/useTriggerExperiment.d.ts +17 -0
  101. package/dist/useTriggerExperiment.js +32 -0
  102. package/dist/useTriggerExperiment.js.map +1 -0
  103. package/dist/useVariationAssociatedData.d.ts +16 -0
  104. package/dist/useVariationAssociatedData.js +30 -0
  105. package/dist/useVariationAssociatedData.js.map +1 -0
  106. package/dist/useVisitorCode.d.ts +12 -0
  107. package/dist/useVisitorCode.js +19 -0
  108. package/dist/useVisitorCode.js.map +1 -0
  109. package/dist/withActivateFeature.d.ts +17 -0
  110. package/dist/withActivateFeature.js +28 -0
  111. package/dist/withActivateFeature.js.map +1 -0
  112. package/dist/withAddData.d.ts +16 -0
  113. package/dist/withAddData.js +65 -0
  114. package/dist/withAddData.js.map +1 -0
  115. package/dist/withBrowser.d.ts +16 -0
  116. package/dist/withBrowser.js +35 -0
  117. package/dist/withBrowser.js.map +1 -0
  118. package/dist/withConversion.d.ts +17 -0
  119. package/dist/withConversion.js +31 -0
  120. package/dist/withConversion.js.map +1 -0
  121. package/dist/withCustomData.d.ts +16 -0
  122. package/dist/withCustomData.js +31 -0
  123. package/dist/withCustomData.js.map +1 -0
  124. package/dist/withDevice.d.ts +15 -0
  125. package/dist/withDevice.js +29 -0
  126. package/dist/withDevice.js.map +1 -0
  127. package/dist/withFeature.d.ts +6 -0
  128. package/dist/withFeature.js +31 -0
  129. package/dist/withFeature.js.map +1 -0
  130. package/dist/withFeatureVariable.d.ts +17 -0
  131. package/dist/withFeatureVariable.js +28 -0
  132. package/dist/withFeatureVariable.js.map +1 -0
  133. package/dist/withFlush.d.ts +14 -0
  134. package/dist/withFlush.js +36 -0
  135. package/dist/withFlush.js.map +1 -0
  136. package/dist/withKameleoon.d.ts +13 -0
  137. package/dist/withKameleoon.js +33 -0
  138. package/dist/withKameleoon.js.map +1 -0
  139. package/dist/withPageView.d.ts +17 -0
  140. package/dist/withPageView.js +31 -0
  141. package/dist/withPageView.js.map +1 -0
  142. package/dist/withRetrieveDataFromRemoteSource.d.ts +14 -0
  143. package/dist/withRetrieveDataFromRemoteSource.js +28 -0
  144. package/dist/withRetrieveDataFromRemoteSource.js.map +1 -0
  145. package/dist/withRunWhenReady.d.ts +16 -0
  146. package/dist/withRunWhenReady.js +28 -0
  147. package/dist/withRunWhenReady.js.map +1 -0
  148. package/dist/withTrackingConversion.d.ts +16 -0
  149. package/dist/withTrackingConversion.js +36 -0
  150. package/dist/withTrackingConversion.js.map +1 -0
  151. package/dist/withTriggerExperiment.d.ts +19 -0
  152. package/dist/withTriggerExperiment.js +30 -0
  153. package/dist/withTriggerExperiment.js.map +1 -0
  154. package/dist/withVariationAssociatedData.d.ts +18 -0
  155. package/dist/withVariationAssociatedData.js +30 -0
  156. package/dist/withVariationAssociatedData.js.map +1 -0
  157. package/dist/withVisitorCode.d.ts +15 -0
  158. package/dist/withVisitorCode.js +36 -0
  159. package/dist/withVisitorCode.js.map +1 -0
  160. package/package.json +1 -1
@@ -0,0 +1,79 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,14 @@
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 {};
@@ -0,0 +1,23 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,13 @@
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 {};
@@ -0,0 +1,19 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,17 @@
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 {};
@@ -0,0 +1,32 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,16 @@
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 {};
@@ -0,0 +1,30 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,12 @@
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 {};
@@ -0,0 +1,19 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,17 @@
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: (featureKey: string | number, visitorCode?: string) => 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 {};
@@ -0,0 +1,28 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,16 @@
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 {};
@@ -0,0 +1,65 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,16 @@
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 {};
@@ -0,0 +1,35 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.withBrowser = void 0;
18
+ var jsx_runtime_1 = require("react/jsx-runtime");
19
+ var react_1 = require("react");
20
+ var data_1 = __importDefault(require("kameleoon-client-javascript/dist/data"));
21
+ var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
22
+ /**
23
+ * A React HOC that gives a wrapped component access to callback function
24
+ * which adds browser type
25
+ */
26
+ function withBrowser(Component) {
27
+ return function WrappedComponent(props) {
28
+ var addBrowser = (0, react_1.useCallback)(function (browser) {
29
+ return new kameleoon_client_javascript_1.KameleoonData.Browser(data_1.default.browsers[browser]);
30
+ }, []);
31
+ return (0, jsx_runtime_1.jsx)(Component, __assign({ addBrowser: addBrowser }, props), void 0);
32
+ };
33
+ }
34
+ exports.withBrowser = withBrowser;
35
+ //# sourceMappingURL=withBrowser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withBrowser.js","sourceRoot":"","sources":["../src/withBrowser.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,+EAE+C;AAC/C,2EAA4D;AAW5D;;;GAGG;AACH,SAAgB,WAAW,CACzB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,UAAC,OAAgB;YAC9C,OAAO,IAAI,2CAAa,CAAC,OAAO,CAAC,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3D,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,uBAAC,SAAS,aAAC,UAAU,EAAE,UAAU,IAAO,KAAe,UAAI,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AAVD,kCAUC"}
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { Conversion } from 'kameleoon-client-javascript/dist/data';
3
+ import { UnknownPropsType, Without } from './types';
4
+ interface IWithConversion {
5
+ /**
6
+ * @param goalId - unique identifier of the goal
7
+ * @param revenue - conversion revenue
8
+ * @param negative - defines if the revenue is positive or negative
9
+ */
10
+ addConversion: (goalId: number, revenue?: number, negative?: boolean) => Conversion;
11
+ }
12
+ /**
13
+ * A React HOC that gives a wrapped component access to callback function
14
+ * which adds conversion
15
+ */
16
+ export declare function withConversion<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithConversion>>;
17
+ export {};
@@ -0,0 +1,31 @@
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.withConversion = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var react_1 = require("react");
17
+ var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
18
+ /**
19
+ * A React HOC that gives a wrapped component access to callback function
20
+ * which adds conversion
21
+ */
22
+ function withConversion(Component) {
23
+ return function WrappedComponent(props) {
24
+ var addConversion = (0, react_1.useCallback)(function (goalId, revenue, negative) {
25
+ return new kameleoon_client_javascript_1.KameleoonData.Conversion(goalId, revenue, negative);
26
+ }, []);
27
+ return (0, jsx_runtime_1.jsx)(Component, __assign({ addConversion: addConversion }, props), void 0);
28
+ };
29
+ }
30
+ exports.withConversion = withConversion;
31
+ //# sourceMappingURL=withConversion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withConversion.js","sourceRoot":"","sources":["../src/withConversion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,2EAA4D;AAiB5D;;;GAGG;AACH,SAAgB,cAAc,CAC5B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,aAAa,GAAG,IAAA,mBAAW,EAC/B,UAAC,MAAc,EAAE,OAAgB,EAAE,QAAkB;YACnD,OAAO,IAAI,2CAAa,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC,EACD,EAAE,CACH,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,aAAa,EAAE,aAAa,IAAO,KAAe,UAAI,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAbD,wCAaC"}
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { CustomData } from 'kameleoon-client-javascript/dist/data';
3
+ import { UnknownPropsType, Without } from './types';
4
+ interface IWithCustomData {
5
+ /**
6
+ * @param index - index or unique identifier of the custom data to be stored
7
+ * @param value - value of the custom data to be stored
8
+ */
9
+ addCustomData: (index: number, value: string) => CustomData;
10
+ }
11
+ /**
12
+ * A React HOC that gives a wrapped component access to callback function
13
+ * which adds custom data
14
+ */
15
+ export declare function withCustomData<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithCustomData>>;
16
+ export {};
@@ -0,0 +1,31 @@
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.withCustomData = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var react_1 = require("react");
17
+ var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
18
+ /**
19
+ * A React HOC that gives a wrapped component access to callback function
20
+ * which adds custom data
21
+ */
22
+ function withCustomData(Component) {
23
+ return function WrappedComponent(props) {
24
+ var addCustomData = (0, react_1.useCallback)(function (goalId, revenue, negative) {
25
+ return new kameleoon_client_javascript_1.KameleoonData.Conversion(goalId, revenue, negative);
26
+ }, []);
27
+ return (0, jsx_runtime_1.jsx)(Component, __assign({ addCustomData: addCustomData }, props), void 0);
28
+ };
29
+ }
30
+ exports.withCustomData = withCustomData;
31
+ //# sourceMappingURL=withCustomData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withCustomData.js","sourceRoot":"","sources":["../src/withCustomData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,2EAA4D;AAY5D;;;GAGG;AACH,SAAgB,cAAc,CAC5B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,aAAa,GAAG,IAAA,mBAAW,EAC/B,UAAC,MAAc,EAAE,OAAgB,EAAE,QAAkB;YACnD,OAAO,IAAI,2CAAa,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC,EACD,EAAE,CACH,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,aAAa,EAAE,aAAa,IAAO,KAAe,UAAI,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAbD,wCAaC"}
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { Device as IDevice, DeviceType } from 'kameleoon-client-javascript/dist/data';
3
+ import { UnknownPropsType, Without } from './types';
4
+ interface IWithDevice {
5
+ /**
6
+ * @param device - device types: Phone, Tablet, Desktop
7
+ */
8
+ addDevice: (device: DeviceType) => IDevice;
9
+ }
10
+ /**
11
+ * A React HOC that gives a wrapped component access to callback function
12
+ * which adds device type
13
+ */
14
+ export declare function withDevice<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithDevice>>;
15
+ export {};