@kameleoon/react-sdk 1.2.2 → 3.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.
- package/CHANGELOG.md +29 -0
- package/README.md +315 -43
- package/dist/Feature.js +2 -2
- package/dist/Feature.js.map +1 -1
- package/dist/KameleoonError.d.ts +5 -0
- package/dist/KameleoonError.js +31 -0
- package/dist/KameleoonError.js.map +1 -0
- package/dist/compose.d.ts +1 -1
- package/dist/compose.js +27 -2
- package/dist/compose.js.map +1 -1
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +13 -1
- package/dist/constants.js.map +1 -1
- package/dist/getKameleoonException.d.ts +2 -0
- package/dist/getKameleoonException.js +34 -0
- package/dist/getKameleoonException.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/dist/stories/Form.d.ts +13 -5
- package/dist/stories/Form.js +154 -36
- package/dist/stories/Form.js.map +1 -1
- package/dist/stories/FormHOC.js +12 -7
- package/dist/stories/FormHOC.js.map +1 -1
- package/dist/stories/FormHook.js +34 -21
- package/dist/stories/FormHook.js.map +1 -1
- package/dist/stories/constants.d.ts +5 -2
- package/dist/stories/constants.js +11 -8
- package/dist/stories/constants.js.map +1 -1
- package/dist/types.d.ts +24 -7
- package/dist/types.js.map +1 -1
- package/dist/useActivateFeature.d.ts +2 -0
- package/dist/useActivateFeature.js +11 -2
- package/dist/useActivateFeature.js.map +1 -1
- package/dist/useAddData.js +17 -1
- package/dist/useAddData.js.map +1 -1
- package/dist/useConversion.d.ts +1 -1
- package/dist/useError.d.ts +7 -0
- package/dist/useError.js +34 -0
- package/dist/useError.js.map +1 -0
- package/dist/useErrors.d.ts +7 -0
- package/dist/useErrors.js +42 -0
- package/dist/useErrors.js.map +1 -0
- package/dist/useFeature.d.ts +1 -1
- package/dist/useFeature.js +42 -13
- package/dist/useFeature.js.map +1 -1
- package/dist/useFeatureVariable.d.ts +2 -0
- package/dist/useFeatureVariable.js +11 -2
- package/dist/useFeatureVariable.js.map +1 -1
- package/dist/useRetrieveDataFromRemoteSource.d.ts +12 -0
- package/dist/useRetrieveDataFromRemoteSource.js +79 -0
- package/dist/useRetrieveDataFromRemoteSource.js.map +1 -0
- package/dist/useRunWhenReady.d.ts +14 -0
- package/dist/useRunWhenReady.js +23 -0
- package/dist/useRunWhenReady.js.map +1 -0
- package/dist/useTriggerExperiment.d.ts +2 -0
- package/dist/useTriggerExperiment.js +12 -2
- package/dist/useTriggerExperiment.js.map +1 -1
- package/dist/useVariationAssociatedData.d.ts +6 -4
- package/dist/useVariationAssociatedData.js +11 -2
- package/dist/useVariationAssociatedData.js.map +1 -1
- package/dist/withActivateFeature.d.ts +2 -0
- package/dist/withActivateFeature.js +3 -12
- package/dist/withActivateFeature.js.map +1 -1
- package/dist/withAddData.js +17 -2
- package/dist/withAddData.js.map +1 -1
- package/dist/withBrowser.js +0 -1
- package/dist/withBrowser.js.map +1 -1
- package/dist/withConversion.d.ts +1 -1
- package/dist/withConversion.js +0 -1
- package/dist/withConversion.js.map +1 -1
- package/dist/withCustomData.js +0 -1
- package/dist/withCustomData.js.map +1 -1
- package/dist/withFeature.js +2 -3
- package/dist/withFeature.js.map +1 -1
- package/dist/withFeatureVariable.d.ts +2 -0
- package/dist/withFeatureVariable.js +2 -2
- package/dist/withFeatureVariable.js.map +1 -1
- package/dist/withFlush.js +0 -1
- package/dist/withFlush.js.map +1 -1
- package/dist/withInterest.js +0 -1
- package/dist/withInterest.js.map +1 -1
- package/dist/withKameleoon.js +0 -1
- package/dist/withKameleoon.js.map +1 -1
- package/dist/withPageView.js +0 -1
- package/dist/withPageView.js.map +1 -1
- package/dist/withRetrieveDataFromRemoteSource.d.ts +14 -0
- package/dist/withRetrieveDataFromRemoteSource.js +28 -0
- package/dist/withRetrieveDataFromRemoteSource.js.map +1 -0
- package/dist/withRunWhenReady.d.ts +16 -0
- package/dist/withRunWhenReady.js +28 -0
- package/dist/withRunWhenReady.js.map +1 -0
- package/dist/withTrackingConversion.d.ts +1 -1
- package/dist/withTrackingConversion.js +4 -6
- package/dist/withTrackingConversion.js.map +1 -1
- package/dist/withTriggerExperiment.d.ts +3 -1
- package/dist/withTriggerExperiment.js +4 -13
- package/dist/withTriggerExperiment.js.map +1 -1
- package/dist/withVariationAssociatedData.d.ts +4 -2
- package/dist/withVariationAssociatedData.js +3 -11
- package/dist/withVariationAssociatedData.js.map +1 -1
- package/dist/withVisitorCode.js +0 -1
- package/dist/withVisitorCode.js.map +1 -1
- package/package.json +3 -2
|
@@ -15,23 +15,21 @@ exports.withTrackingConversion = void 0;
|
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
var react_1 = require("react");
|
|
17
17
|
var ProviderError_1 = require("./ProviderError");
|
|
18
|
-
var
|
|
18
|
+
var KameleoonContext_1 = require("./KameleoonContext");
|
|
19
19
|
/**
|
|
20
|
-
* A React HOC that gives a wrapped component access
|
|
20
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
21
21
|
* which tracks conversion
|
|
22
22
|
*/
|
|
23
23
|
function withTrackingConversion(Component) {
|
|
24
24
|
return function WrappedComponent(props) {
|
|
25
|
-
var client = (0, react_1.useContext)(
|
|
25
|
+
var client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
|
|
26
26
|
var trackConversion = (0, react_1.useCallback)(function (visitorCode, goalId, revenue) {
|
|
27
27
|
if (!client) {
|
|
28
28
|
throw new ProviderError_1.ProviderError('withTrackingConversion');
|
|
29
29
|
}
|
|
30
30
|
return client.trackConversion(visitorCode, goalId, revenue);
|
|
31
31
|
}, [client]);
|
|
32
|
-
return (
|
|
33
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
34
|
-
(0, jsx_runtime_1.jsx)(Component, __assign({ trackConversion: trackConversion }, props), void 0));
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(Component, __assign({ trackConversion: trackConversion }, props), void 0));
|
|
35
33
|
};
|
|
36
34
|
}
|
|
37
35
|
exports.withTrackingConversion = withTrackingConversion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTrackingConversion.js","sourceRoot":"","sources":["../src/withTrackingConversion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAuD;AAEvD,iDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"withTrackingConversion.js","sourceRoot":"","sources":["../src/withTrackingConversion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAuD;AAEvD,iDAAgD;AAChD,uDAAsD;AAetD;;;GAGG;AACH,SAAgB,sBAAsB,CACpC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,eAAe,GAAG,IAAA,mBAAW,EACjC,UAAC,WAAmB,EAAE,MAAc,EAAE,OAAgB;YACpD,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,wBAAwB,CAAC,CAAC;aACnD;YAED,OAAO,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9D,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,CACL,uBAAC,SAAS,aAAC,eAAe,EAAE,eAAe,IAAO,KAAe,UAAI,CACtE,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AArBD,wDAqBC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { KameleoonError } from './KameleoonError';
|
|
2
3
|
import { UnknownPropsType, Without } from './types';
|
|
3
4
|
interface IWithTriggerExperiment {
|
|
4
5
|
/**
|
|
@@ -6,9 +7,10 @@ interface IWithTriggerExperiment {
|
|
|
6
7
|
* @param experimentId - unique identifier of the experiment you want to expose to a user
|
|
7
8
|
*/
|
|
8
9
|
getVariationId: (visitorCode: string, experimentId: number) => number;
|
|
10
|
+
triggerExperimentError: KameleoonError | null;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
|
-
* A React HOC that gives a wrapped component access
|
|
13
|
+
* A React HOC that gives a wrapped component access to callback function which triggers experiment
|
|
12
14
|
* If such a user has never been associated with any variation, the SDK returns a randomly selected variation.
|
|
13
15
|
* If a user with a given visitorCode is already registered with a variation,
|
|
14
16
|
* it will detect the previously registered variation and return the variationID
|
|
@@ -13,26 +13,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.withTriggerExperiment = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
-
var
|
|
17
|
-
var KameleoonContext_1 = require("./KameleoonContext");
|
|
18
|
-
var ProviderError_1 = require("./ProviderError");
|
|
16
|
+
var useTriggerExperiment_1 = require("./useTriggerExperiment");
|
|
19
17
|
/**
|
|
20
|
-
* A React HOC that gives a wrapped component access
|
|
18
|
+
* A React HOC that gives a wrapped component access to callback function which triggers experiment
|
|
21
19
|
* If such a user has never been associated with any variation, the SDK returns a randomly selected variation.
|
|
22
20
|
* If a user with a given visitorCode is already registered with a variation,
|
|
23
21
|
* it will detect the previously registered variation and return the variationID
|
|
24
22
|
*/
|
|
25
23
|
function withTriggerExperiment(Component) {
|
|
26
24
|
return function WrappedComponent(props) {
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
if (!client) {
|
|
30
|
-
throw new ProviderError_1.ProviderError('withTriggerExperiment');
|
|
31
|
-
}
|
|
32
|
-
return client.triggerExperiment(visitorCode, experimentId);
|
|
33
|
-
}, [client]);
|
|
34
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
35
|
-
return (0, jsx_runtime_1.jsx)(Component, __assign({ getVariationId: getVariationId }, props), void 0);
|
|
25
|
+
var _a = (0, useTriggerExperiment_1.useTriggerExperiment)(), getVariationId = _a.getVariationId, triggerExperimentError = _a.error;
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(Component, __assign({ getVariationId: getVariationId, triggerExperimentError: triggerExperimentError }, props), void 0));
|
|
36
27
|
};
|
|
37
28
|
}
|
|
38
29
|
exports.withTriggerExperiment = withTriggerExperiment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTriggerExperiment.js","sourceRoot":"","sources":["../src/withTriggerExperiment.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"withTriggerExperiment.js","sourceRoot":"","sources":["../src/withTriggerExperiment.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,+DAA8D;AAW9D;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACrC,IAAA,KACJ,IAAA,2CAAoB,GAAE,EADhB,cAAc,oBAAA,EAAS,sBAAsB,WAC7B,CAAC;QAEzB,OAAO,CACL,uBAAC,SAAS,aACR,cAAc,EAAE,cAAc,EAC9B,sBAAsB,EAAE,sBAAsB,IACzC,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAfD,sDAeC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { UnknownPropsType, Without,
|
|
2
|
+
import { UnknownPropsType, Without, VariationAssociatedDataType } from './types';
|
|
3
|
+
import { KameleoonError } from './KameleoonError';
|
|
3
4
|
interface IWithVariationAssociatedData {
|
|
4
5
|
/**
|
|
5
6
|
* @param variationId - unique identifier of the variation you want to obtain associated data for
|
|
6
7
|
*/
|
|
7
|
-
getVariationAssociatedData: (variationId: number) =>
|
|
8
|
+
getVariationAssociatedData: (variationId: number) => VariationAssociatedDataType;
|
|
9
|
+
variationAssociatedDataError: KameleoonError | null;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* A React HOC that gives a wrapped component access to callback function which
|
|
@@ -13,9 +13,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.withVariationAssociatedData = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
-
var
|
|
17
|
-
var KameleoonContext_1 = require("./KameleoonContext");
|
|
18
|
-
var ProviderError_1 = require("./ProviderError");
|
|
16
|
+
var useVariationAssociatedData_1 = require("./useVariationAssociatedData");
|
|
19
17
|
/**
|
|
20
18
|
* A React HOC that gives a wrapped component access to callback function which
|
|
21
19
|
* retrieves JSON data associated with a variation.
|
|
@@ -24,14 +22,8 @@ var ProviderError_1 = require("./ProviderError");
|
|
|
24
22
|
*/
|
|
25
23
|
function withVariationAssociatedData(Component) {
|
|
26
24
|
return function WrappedComponent(props) {
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
if (!client) {
|
|
30
|
-
throw new ProviderError_1.ProviderError('withVariationAssociatedData');
|
|
31
|
-
}
|
|
32
|
-
return client.obtainVariationAssociatedData(variationId);
|
|
33
|
-
}, [client]);
|
|
34
|
-
return ((0, jsx_runtime_1.jsx)(Component, __assign({ getVariationAssociatedData: getVariationAssociatedData }, props), void 0));
|
|
25
|
+
var _a = (0, useVariationAssociatedData_1.useVariationAssociatedData)(), getVariationAssociatedData = _a.getVariationAssociatedData, variationAssociatedDataError = _a.error;
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(Component, __assign({ getVariationAssociatedData: getVariationAssociatedData, variationAssociatedDataError: variationAssociatedDataError }, props), void 0));
|
|
35
27
|
};
|
|
36
28
|
}
|
|
37
29
|
exports.withVariationAssociatedData = withVariationAssociatedData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withVariationAssociatedData.js","sourceRoot":"","sources":["../src/withVariationAssociatedData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"withVariationAssociatedData.js","sourceRoot":"","sources":["../src/withVariationAssociatedData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA,2EAA0E;AAa1E;;;;;GAKG;AACH,SAAgB,2BAA2B,CACzC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACrC,IAAA,KACJ,IAAA,uDAA0B,GAAE,EADtB,0BAA0B,gCAAA,EAAS,4BAA4B,WACzC,CAAC;QAE/B,OAAO,CACL,uBAAC,SAAS,aACR,0BAA0B,EAAE,0BAA0B,EACtD,4BAA4B,EAAE,4BAA4B,IACrD,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAfD,kEAeC"}
|
package/dist/withVisitorCode.js
CHANGED
|
@@ -29,7 +29,6 @@ function withVisitorCode(Component) {
|
|
|
29
29
|
}
|
|
30
30
|
return client.obtainVisitorCode(topLevelDomain, defaultVisitorCode);
|
|
31
31
|
}, [client]);
|
|
32
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
33
32
|
return (0, jsx_runtime_1.jsx)(Component, __assign({ getVisitorCode: getVisitorCode }, props), void 0);
|
|
34
33
|
};
|
|
35
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withVisitorCode.js","sourceRoot":"","sources":["../src/withVisitorCode.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAuD;AAEvD,uDAAsD;AACtD,iDAAgD;AAahD;;;GAGG;AACH,SAAgB,eAAe,CAC7B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,UAAC,cAAsB,EAAE,kBAA2B;YAClD,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,iBAAiB,CAAC,CAAC;aAC5C;YAED,OAAO,MAAM,CAAC,iBAAiB,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QACtE,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,
|
|
1
|
+
{"version":3,"file":"withVisitorCode.js","sourceRoot":"","sources":["../src/withVisitorCode.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAuD;AAEvD,uDAAsD;AACtD,iDAAgD;AAahD;;;GAGG;AACH,SAAgB,eAAe,CAC7B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,UAAC,cAAsB,EAAE,kBAA2B;YAClD,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,iBAAiB,CAAC,CAAC;aAC5C;YAED,OAAO,MAAM,CAAC,iBAAiB,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QACtE,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,cAAc,EAAE,cAAc,IAAO,KAAe,UAAI,CAAC;IAC7E,CAAC,CAAC;AACJ,CAAC;AAnBD,0CAmBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kameleoon/react-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Kameleoon React SDK",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"build": "npm run clear && tsc",
|
|
13
13
|
"deploy": "npm publish --tag latest --access public",
|
|
14
14
|
"release": "../../scripts/release.sh react-sdk",
|
|
15
|
+
"update-documentation": "../../scripts/update_documentation.sh react",
|
|
15
16
|
"test": "jest",
|
|
16
17
|
"test:watch": "jest --watch",
|
|
17
18
|
"test:coverage": "jest --coverage",
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
37
|
"@types/validator": "^13.6.3",
|
|
37
|
-
"kameleoon-client-javascript": "^1.0.
|
|
38
|
+
"kameleoon-client-javascript": "^1.0.8",
|
|
38
39
|
"validator": "^13.6.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|