@kameleoon/react-sdk 2.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 (138) hide show
  1. package/README.md +322 -53
  2. package/package.json +3 -2
  3. package/CHANGELOG.md +0 -61
  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/KameleoonProvider.d.ts +0 -14
  11. package/dist/KameleoonProvider.js +0 -25
  12. package/dist/KameleoonProvider.js.map +0 -1
  13. package/dist/ProviderError.d.ts +0 -3
  14. package/dist/ProviderError.js +0 -29
  15. package/dist/ProviderError.js.map +0 -1
  16. package/dist/compose.d.ts +0 -8
  17. package/dist/compose.js +0 -33
  18. package/dist/compose.js.map +0 -1
  19. package/dist/constants.d.ts +0 -14
  20. package/dist/constants.js +0 -20
  21. package/dist/constants.js.map +0 -1
  22. package/dist/index.d.ts +0 -37
  23. package/dist/index.js +0 -85
  24. package/dist/index.js.map +0 -1
  25. package/dist/kameleoonClient.d.ts +0 -16
  26. package/dist/kameleoonClient.js +0 -17
  27. package/dist/kameleoonClient.js.map +0 -1
  28. package/dist/stories/Form.d.ts +0 -22
  29. package/dist/stories/Form.js +0 -98
  30. package/dist/stories/Form.js.map +0 -1
  31. package/dist/stories/FormHOC.d.ts +0 -2
  32. package/dist/stories/FormHOC.js +0 -41
  33. package/dist/stories/FormHOC.js.map +0 -1
  34. package/dist/stories/FormHook.d.ts +0 -2
  35. package/dist/stories/FormHook.js +0 -66
  36. package/dist/stories/FormHook.js.map +0 -1
  37. package/dist/stories/FormRenderProps.d.ts +0 -3
  38. package/dist/stories/FormRenderProps.js +0 -24
  39. package/dist/stories/FormRenderProps.js.map +0 -1
  40. package/dist/stories/Radio.d.ts +0 -8
  41. package/dist/stories/Radio.js +0 -9
  42. package/dist/stories/Radio.js.map +0 -1
  43. package/dist/stories/constants.d.ts +0 -14
  44. package/dist/stories/constants.js +0 -19
  45. package/dist/stories/constants.js.map +0 -1
  46. package/dist/types.d.ts +0 -24
  47. package/dist/types.js +0 -4
  48. package/dist/types.js.map +0 -1
  49. package/dist/useActivateFeature.d.ts +0 -12
  50. package/dist/useActivateFeature.js +0 -23
  51. package/dist/useActivateFeature.js.map +0 -1
  52. package/dist/useAddData.d.ts +0 -14
  53. package/dist/useAddData.js +0 -33
  54. package/dist/useAddData.js.map +0 -1
  55. package/dist/useBrowser.d.ts +0 -13
  56. package/dist/useBrowser.js +0 -22
  57. package/dist/useBrowser.js.map +0 -1
  58. package/dist/useConversion.d.ts +0 -14
  59. package/dist/useConversion.js +0 -18
  60. package/dist/useConversion.js.map +0 -1
  61. package/dist/useCustomData.d.ts +0 -13
  62. package/dist/useCustomData.js +0 -18
  63. package/dist/useCustomData.js.map +0 -1
  64. package/dist/useFeature.d.ts +0 -5
  65. package/dist/useFeature.js +0 -83
  66. package/dist/useFeature.js.map +0 -1
  67. package/dist/useFeatureVariable.d.ts +0 -13
  68. package/dist/useFeatureVariable.js +0 -36
  69. package/dist/useFeatureVariable.js.map +0 -1
  70. package/dist/useFlush.d.ts +0 -11
  71. package/dist/useFlush.js +0 -19
  72. package/dist/useFlush.js.map +0 -1
  73. package/dist/useInterest.d.ts +0 -12
  74. package/dist/useInterest.js +0 -16
  75. package/dist/useInterest.js.map +0 -1
  76. package/dist/useKameleoon.d.ts +0 -10
  77. package/dist/useKameleoon.js +0 -20
  78. package/dist/useKameleoon.js.map +0 -1
  79. package/dist/usePageView.d.ts +0 -14
  80. package/dist/usePageView.js +0 -18
  81. package/dist/usePageView.js.map +0 -1
  82. package/dist/useTrackingConversion.d.ts +0 -13
  83. package/dist/useTrackingConversion.js +0 -19
  84. package/dist/useTrackingConversion.js.map +0 -1
  85. package/dist/useTriggerExperiment.d.ts +0 -15
  86. package/dist/useTriggerExperiment.js +0 -22
  87. package/dist/useTriggerExperiment.js.map +0 -1
  88. package/dist/useVariationAssociatedData.d.ts +0 -14
  89. package/dist/useVariationAssociatedData.js +0 -21
  90. package/dist/useVariationAssociatedData.js.map +0 -1
  91. package/dist/useVisitorCode.d.ts +0 -12
  92. package/dist/useVisitorCode.js +0 -19
  93. package/dist/useVisitorCode.js.map +0 -1
  94. package/dist/withActivateFeature.d.ts +0 -15
  95. package/dist/withActivateFeature.js +0 -36
  96. package/dist/withActivateFeature.js.map +0 -1
  97. package/dist/withAddData.d.ts +0 -16
  98. package/dist/withAddData.js +0 -49
  99. package/dist/withAddData.js.map +0 -1
  100. package/dist/withBrowser.d.ts +0 -16
  101. package/dist/withBrowser.js +0 -35
  102. package/dist/withBrowser.js.map +0 -1
  103. package/dist/withConversion.d.ts +0 -17
  104. package/dist/withConversion.js +0 -31
  105. package/dist/withConversion.js.map +0 -1
  106. package/dist/withCustomData.d.ts +0 -16
  107. package/dist/withCustomData.js +0 -31
  108. package/dist/withCustomData.js.map +0 -1
  109. package/dist/withFeature.d.ts +0 -6
  110. package/dist/withFeature.js +0 -31
  111. package/dist/withFeature.js.map +0 -1
  112. package/dist/withFeatureVariable.d.ts +0 -15
  113. package/dist/withFeatureVariable.js +0 -28
  114. package/dist/withFeatureVariable.js.map +0 -1
  115. package/dist/withFlush.d.ts +0 -14
  116. package/dist/withFlush.js +0 -36
  117. package/dist/withFlush.js.map +0 -1
  118. package/dist/withInterest.d.ts +0 -15
  119. package/dist/withInterest.js +0 -31
  120. package/dist/withInterest.js.map +0 -1
  121. package/dist/withKameleoon.d.ts +0 -13
  122. package/dist/withKameleoon.js +0 -33
  123. package/dist/withKameleoon.js.map +0 -1
  124. package/dist/withPageView.d.ts +0 -17
  125. package/dist/withPageView.js +0 -31
  126. package/dist/withPageView.js.map +0 -1
  127. package/dist/withTrackingConversion.d.ts +0 -16
  128. package/dist/withTrackingConversion.js +0 -36
  129. package/dist/withTrackingConversion.js.map +0 -1
  130. package/dist/withTriggerExperiment.d.ts +0 -17
  131. package/dist/withTriggerExperiment.js +0 -38
  132. package/dist/withTriggerExperiment.js.map +0 -1
  133. package/dist/withVariationAssociatedData.d.ts +0 -16
  134. package/dist/withVariationAssociatedData.js +0 -38
  135. package/dist/withVariationAssociatedData.js.map +0 -1
  136. package/dist/withVisitorCode.d.ts +0 -15
  137. package/dist/withVisitorCode.js +0 -36
  138. 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,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,15 +0,0 @@
1
- interface IGetVariationIdHookResult {
2
- /**
3
- * @param visitorCode - unique identifier of the user
4
- * @param experimentId - unique identifier of the experiment you want to expose to a user
5
- */
6
- getVariationId: (visitorCode: string, experimentId: number) => number;
7
- }
8
- /**
9
- * A React Hook that returns callback function which triggers experiment.
10
- * If such a user has never been associated with any variation, the SDK returns a randomly selected variation.
11
- * If a user with a given visitorCode is already registered with a variation,
12
- * it will detect the previously registered variation and return the variationID
13
- */
14
- export declare function useTriggerExperiment(): IGetVariationIdHookResult;
15
- export {};
@@ -1,22 +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
- /**
7
- * A React Hook that returns callback function which triggers experiment.
8
- * If such a user has never been associated with any variation, the SDK returns a randomly selected variation.
9
- * If a user with a given visitorCode is already registered with a variation,
10
- * it will detect the previously registered variation and return the variationID
11
- */
12
- function useTriggerExperiment() {
13
- var client = (0, useKameleoon_1.useKameleoon)().client;
14
- var getVariationId = (0, react_1.useCallback)(function (visitorCode, experimentId) {
15
- return client.triggerExperiment(visitorCode, experimentId);
16
- }, [client]);
17
- return {
18
- getVariationId: getVariationId,
19
- };
20
- }
21
- exports.useTriggerExperiment = useTriggerExperiment;
22
- //# sourceMappingURL=useTriggerExperiment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTriggerExperiment.js","sourceRoot":"","sources":["../src/useTriggerExperiment.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAU9C;;;;;GAKG;AACH,SAAgB,oBAAoB;IAC1B,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,UAAC,WAAmB,EAAE,YAAoB;QACxC,OAAA,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,YAAY,CAAC;IAAnD,CAAmD,EACrD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,cAAc,gBAAA;KACf,CAAC;AACJ,CAAC;AAZD,oDAYC"}
@@ -1,14 +0,0 @@
1
- import { AnyType } from './types';
2
- interface VariationAssociatedDataHookResult {
3
- /**
4
- * @param variationId - unique identifier of the variation you want to obtain associated data for
5
- */
6
- getVariationAssociatedData: (variationId: number) => AnyType;
7
- }
8
- /**
9
- * A React Hook that returns callback function which retrieves JSON data associated with a variation.
10
- * The JSON data usually represents some metadata of the variation,
11
- * and can be configured on our web application interface or via our Automation API.
12
- */
13
- export declare function useVariationAssociatedData(): VariationAssociatedDataHookResult;
14
- export {};
@@ -1,21 +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
- /**
7
- * A React Hook that returns callback function which retrieves JSON data associated with a variation.
8
- * The JSON data usually represents some metadata of the variation,
9
- * and can be configured on our web application interface or via our Automation API.
10
- */
11
- function useVariationAssociatedData() {
12
- var client = (0, useKameleoon_1.useKameleoon)().client;
13
- var getVariationAssociatedData = (0, react_1.useCallback)(function (variationId) {
14
- return client.obtainVariationAssociatedData(variationId);
15
- }, [client]);
16
- return {
17
- getVariationAssociatedData: getVariationAssociatedData,
18
- };
19
- }
20
- exports.useVariationAssociatedData = useVariationAssociatedData;
21
- //# sourceMappingURL=useVariationAssociatedData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useVariationAssociatedData.js","sourceRoot":"","sources":["../src/useVariationAssociatedData.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAU9C;;;;GAIG;AACH,SAAgB,0BAA0B;IAChC,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,0BAA0B,GAAG,IAAA,mBAAW,EAC5C,UAAC,WAAmB;QAClB,OAAA,MAAM,CAAC,6BAA6B,CAAC,WAAW,CAAC;IAAjD,CAAiD,EACnD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,0BAA0B,4BAAA;KAC3B,CAAC;AACJ,CAAC;AAZD,gEAYC"}
@@ -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,15 +0,0 @@
1
- import React from 'react';
2
- import { UnknownPropsType, Without } from './types';
3
- interface IWithHasFeature {
4
- /**
5
- * @param visitorCode - unique identifier of the user
6
- * @param featureKey - unique identifier or key of the feature you want to expose to a user
7
- */
8
- hasFeature: (visitorCode: string, featureKey: string | number) => boolean;
9
- }
10
- /**
11
- * A React HOC that gives a wrapped component access to callback
12
- * function which activates a feature toggle
13
- */
14
- export declare function withActivateFeature<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithHasFeature>>;
15
- export {};
@@ -1,36 +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 react_1 = require("react");
17
- var KameleoonContext_1 = require("./KameleoonContext");
18
- var ProviderError_1 = require("./ProviderError");
19
- /**
20
- * A React HOC that gives a wrapped component access to callback
21
- * function which activates a feature toggle
22
- */
23
- function withActivateFeature(Component) {
24
- return function WrappedComponent(props) {
25
- var client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
26
- var hasFeature = (0, react_1.useCallback)(function (visitorCode, featureKey) {
27
- if (!client) {
28
- throw new ProviderError_1.ProviderError('withActivateFeature');
29
- }
30
- return client.activateFeature(visitorCode, featureKey);
31
- }, [client]);
32
- return (0, jsx_runtime_1.jsx)(Component, __assign({ hasFeature: hasFeature }, props), void 0);
33
- };
34
- }
35
- exports.withActivateFeature = withActivateFeature;
36
- //# sourceMappingURL=withActivateFeature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withActivateFeature.js","sourceRoot":"","sources":["../src/withActivateFeature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAuD;AAEvD,uDAAsD;AACtD,iDAAgD;AAUhD;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,UAAU,GAAG,IAAA,mBAAW,EAC5B,UAAC,WAAmB,EAAE,UAA2B;YAC/C,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,qBAAqB,CAAC,CAAC;aAChD;YAED,OAAO,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACzD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,UAAU,EAAE,UAAU,IAAO,KAAe,UAAI,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AAnBD,kDAmBC"}
@@ -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,49 +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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.withAddData = void 0;
24
- var jsx_runtime_1 = require("react/jsx-runtime");
25
- var react_1 = require("react");
26
- var KameleoonContext_1 = require("./KameleoonContext");
27
- var ProviderError_1 = require("./ProviderError");
28
- /**
29
- * A React HOC that gives a wrapped component access to callback function
30
- * which adds various data to associate this data with the current user
31
- */
32
- function withAddData(Component) {
33
- return function WrappedComponent(props) {
34
- var client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
35
- var addData = (0, react_1.useCallback)(function (visitorCode) {
36
- var dataTypes = [];
37
- for (var _i = 1; _i < arguments.length; _i++) {
38
- dataTypes[_i - 1] = arguments[_i];
39
- }
40
- if (!client) {
41
- throw new ProviderError_1.ProviderError('withAddData');
42
- }
43
- return client.addData.apply(client, __spreadArray([visitorCode], dataTypes, false));
44
- }, [client]);
45
- return (0, jsx_runtime_1.jsx)(Component, __assign({ addData: addData }, props), void 0);
46
- };
47
- }
48
- exports.withAddData = withAddData;
49
- //# 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,GAAK,SAAS,UAAE;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 {};
@@ -1,35 +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 __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
@@ -1 +0,0 @@
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"}
@@ -1,17 +0,0 @@
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 {};
@@ -1,31 +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.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
@@ -1 +0,0 @@
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"}
@@ -1,16 +0,0 @@
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 {};
@@ -1,31 +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.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
@@ -1 +0,0 @@
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"}
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { Without, IFeatureParams, UnknownPropsType } from './types';
3
- /**
4
- * A React HOC that gives a wrapped component access to the status of a feature flag and its variables
5
- */
6
- export declare function withFeature(args: IFeatureParams): <Props extends UnknownPropsType>(Component: React.ComponentType<Props>) => React.ComponentType<Props & Without<Props, IFeatureParams>>;
@@ -1,31 +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.withFeature = void 0;
15
- var jsx_runtime_1 = require("react/jsx-runtime");
16
- var useFeature_1 = require("./useFeature");
17
- /**
18
- * A React HOC that gives a wrapped component access to the status of a feature flag and its variables
19
- */
20
- function withFeature(args) {
21
- // Returns curried function that can be used with the specified args
22
- // e.g. withFeature(...args)(Component)
23
- return function callbackWithArgs(Component) {
24
- return function WrappedComponent(props) {
25
- var feature = (0, useFeature_1.useFeature)(__assign({}, args));
26
- return (0, jsx_runtime_1.jsx)(Component, __assign({ feature: feature }, props), void 0);
27
- };
28
- };
29
- }
30
- exports.withFeature = withFeature;
31
- //# sourceMappingURL=withFeature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withFeature.js","sourceRoot":"","sources":["../src/withFeature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,2CAA0C;AAE1C;;GAEG;AACH,SAAgB,WAAW,CAAC,IAAoB;IAC9C,oEAAoE;IACpE,uCAAuC;IACvC,OAAO,SAAS,gBAAgB,CAC9B,SAAqC;QAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;YAC3C,IAAM,OAAO,GAAG,IAAA,uBAAU,eAAM,IAAI,EAAG,CAAC;YAExC,OAAO,uBAAC,SAAS,aAAC,OAAO,EAAE,OAAO,IAAO,KAAe,UAAI,CAAC;QAC/D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAZD,kCAYC"}