@kameleoon/react-sdk 3.0.0 → 4.0.2
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/README.md +37 -38
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/useActivateFeature.d.ts +1 -1
- package/dist/useActivateFeature.js +10 -5
- package/dist/useActivateFeature.js.map +1 -1
- package/dist/useDevice.d.ts +12 -0
- package/dist/useDevice.js +16 -0
- package/dist/useDevice.js.map +1 -0
- package/dist/useFeature.js +1 -1
- package/dist/useFeature.js.map +1 -1
- package/dist/useFeatureVariable.js +4 -6
- package/dist/useFeatureVariable.js.map +1 -1
- package/dist/useTriggerExperiment.js +4 -2
- package/dist/useTriggerExperiment.js.map +1 -1
- package/dist/useVariationAssociatedData.js +4 -2
- package/dist/useVariationAssociatedData.js.map +1 -1
- package/dist/withActivateFeature.d.ts +1 -1
- package/dist/withDevice.d.ts +15 -0
- package/dist/{withInterest.js → withDevice.js} +7 -9
- package/dist/withDevice.js.map +1 -0
- package/package.json +3 -2
- package/CHANGELOG.md +0 -80
- package/dist/stories/Form.d.ts +0 -30
- package/dist/stories/Form.js +0 -215
- package/dist/stories/Form.js.map +0 -1
- package/dist/stories/FormHOC.d.ts +0 -2
- package/dist/stories/FormHOC.js +0 -41
- package/dist/stories/FormHOC.js.map +0 -1
- package/dist/stories/FormHook.d.ts +0 -2
- package/dist/stories/FormHook.js +0 -74
- package/dist/stories/FormHook.js.map +0 -1
- package/dist/stories/FormRenderProps.d.ts +0 -3
- package/dist/stories/FormRenderProps.js +0 -24
- package/dist/stories/FormRenderProps.js.map +0 -1
- package/dist/stories/Radio.d.ts +0 -8
- package/dist/stories/Radio.js +0 -9
- package/dist/stories/Radio.js.map +0 -1
- package/dist/stories/constants.d.ts +0 -16
- package/dist/stories/constants.js +0 -21
- package/dist/stories/constants.js.map +0 -1
- package/dist/useInterest.d.ts +0 -12
- package/dist/useInterest.js +0 -16
- package/dist/useInterest.js.map +0 -1
- package/dist/withInterest.d.ts +0 -15
- package/dist/withInterest.js.map +0 -1
package/README.md
CHANGED
|
@@ -470,8 +470,8 @@ If feature flag is not activated, `KameleoonException.FeatureConfigurationNotFou
|
|
|
470
470
|
|
|
471
471
|
#### `hasFeature()`
|
|
472
472
|
##### Arguments
|
|
473
|
-
- `visitorCode: string` - unique identifier of the user.
|
|
474
473
|
- `featureKey: string | number` - unique identifier or key of the feature you want to expose to a user.
|
|
474
|
+
- `visitorCode: string` (optional) - unique identifier of the user.
|
|
475
475
|
|
|
476
476
|
##### Returns
|
|
477
477
|
- A `value: boolean` of the feature that is registered for a given `visitorCode`.
|
|
@@ -502,7 +502,7 @@ function MyComponent(): JSX.Element {
|
|
|
502
502
|
// Handle exception
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
-
const feature = hasFeature(
|
|
505
|
+
const feature = hasFeature(featureKey, visitorCode);
|
|
506
506
|
}, []);
|
|
507
507
|
|
|
508
508
|
...
|
|
@@ -534,7 +534,7 @@ class MyComponent extends React.Component {
|
|
|
534
534
|
// Handle exception
|
|
535
535
|
}
|
|
536
536
|
|
|
537
|
-
const feature = hasFeature(
|
|
537
|
+
const feature = hasFeature(featureKey, visitorCode);
|
|
538
538
|
}
|
|
539
539
|
|
|
540
540
|
...
|
|
@@ -820,7 +820,7 @@ _The `triggerExperiment()` and `trackConversion()` callback functions also sends
|
|
|
820
820
|
#### `addData()`
|
|
821
821
|
##### Arguments
|
|
822
822
|
- `visitorCode: string` - unique identifier of the user.
|
|
823
|
-
- `dataTypes: DataInterface[]` - custom data types.
|
|
823
|
+
- `dataTypes: DataInterface[]` - custom data types which may be passed separated by a comma.
|
|
824
824
|
|
|
825
825
|
### `useAddData`
|
|
826
826
|
#### Returns
|
|
@@ -848,10 +848,10 @@ function MyComponent(): JSX.Element {
|
|
|
848
848
|
const visitorCode = getVisitorCode('example.com');
|
|
849
849
|
|
|
850
850
|
// Single data type passed
|
|
851
|
-
addData(visitorCode,
|
|
851
|
+
addData(visitorCode, addBrowser(Browser.Chrome));
|
|
852
852
|
|
|
853
853
|
// Several data types passed
|
|
854
|
-
addData(visitorCode,
|
|
854
|
+
addData(visitorCode, addBrowser(Browser.Chrome), addCustomData(1, 'some custom value'));
|
|
855
855
|
}, []);
|
|
856
856
|
|
|
857
857
|
...
|
|
@@ -882,13 +882,10 @@ class MyComponent extends React.Component {
|
|
|
882
882
|
const visitorCode = getVisitorCode('example.com');
|
|
883
883
|
|
|
884
884
|
// Single data type passed
|
|
885
|
-
addData(visitorCode,
|
|
885
|
+
addData(visitorCode, addBrowser(Browser.Chrome));
|
|
886
886
|
|
|
887
887
|
// Several data types passed
|
|
888
|
-
addData(visitorCode,
|
|
889
|
-
addBrowser(Browser.Chrome),
|
|
890
|
-
addCustomData(1, 'some custom value'),
|
|
891
|
-
]);
|
|
888
|
+
addData(visitorCode, addBrowser(Browser.Chrome), addCustomData(1, 'some custom value'));
|
|
892
889
|
}
|
|
893
890
|
|
|
894
891
|
...
|
|
@@ -935,7 +932,7 @@ function MyComponent(): JSX.Element {
|
|
|
935
932
|
useEffect(() => {
|
|
936
933
|
const visitorCode = getVisitorCode('example.com');
|
|
937
934
|
|
|
938
|
-
addData(visitorCode,
|
|
935
|
+
addData(visitorCode, addBrowser(Browser.Chrome));
|
|
939
936
|
flush(visitorCode);
|
|
940
937
|
}, []);
|
|
941
938
|
|
|
@@ -966,7 +963,7 @@ class MyComponent extends React.Component {
|
|
|
966
963
|
const { addData, addBrowser, flush, getVisitorCode } = this.props;
|
|
967
964
|
const visitorCode = getVisitorCode('example.com');
|
|
968
965
|
|
|
969
|
-
addData(visitorCode,
|
|
966
|
+
addData(visitorCode, addBrowser(Browser.Chrome));
|
|
970
967
|
flush(visitorCode);
|
|
971
968
|
}
|
|
972
969
|
|
|
@@ -1089,7 +1086,7 @@ function MyComponent(): JSX.Element {
|
|
|
1089
1086
|
useEffect(() => {
|
|
1090
1087
|
const visitorCode = getVisitorCode('example.com');
|
|
1091
1088
|
|
|
1092
|
-
addData(visitorCode,
|
|
1089
|
+
addData(visitorCode, addBrowser(Browser.Chrome));
|
|
1093
1090
|
}, []);
|
|
1094
1091
|
|
|
1095
1092
|
...
|
|
@@ -1118,7 +1115,7 @@ class MyComponent extends React.Component {
|
|
|
1118
1115
|
const { addData, addBrowser, getVisitorCode } = this.props;
|
|
1119
1116
|
const visitorCode = getVisitorCode('example.com');
|
|
1120
1117
|
|
|
1121
|
-
addData(visitorCode,
|
|
1118
|
+
addData(visitorCode, addBrowser(Browser.Chrome));
|
|
1122
1119
|
}
|
|
1123
1120
|
|
|
1124
1121
|
...
|
|
@@ -1159,7 +1156,7 @@ function MyComponent(): JSX.Element {
|
|
|
1159
1156
|
useEffect(() => {
|
|
1160
1157
|
const visitorCode = getVisitorCode('example.com');
|
|
1161
1158
|
|
|
1162
|
-
addData(visitorCode,
|
|
1159
|
+
addData(visitorCode, addPageView('example.com', 'title', 3));
|
|
1163
1160
|
}, []);
|
|
1164
1161
|
|
|
1165
1162
|
...
|
|
@@ -1190,7 +1187,7 @@ class MyComponent extends React.Component {
|
|
|
1190
1187
|
const { addData, addPageView, getVisitorCode } = this.props;
|
|
1191
1188
|
const visitorCode = getVisitorCode('example.com');
|
|
1192
1189
|
|
|
1193
|
-
addData(visitorCode,
|
|
1190
|
+
addData(visitorCode, addPageView('example.com', 'title', 3));
|
|
1194
1191
|
}
|
|
1195
1192
|
|
|
1196
1193
|
...
|
|
@@ -1232,7 +1229,7 @@ function MyComponent(): JSX.Element {
|
|
|
1232
1229
|
useEffect(() => {
|
|
1233
1230
|
const visitorCode = getVisitorCode('example.com');
|
|
1234
1231
|
|
|
1235
|
-
addData(visitorCode,
|
|
1232
|
+
addData(visitorCode, addConversion(32, 10, false));
|
|
1236
1233
|
}, []);
|
|
1237
1234
|
|
|
1238
1235
|
...
|
|
@@ -1260,7 +1257,7 @@ class MyComponent extends React.Component {
|
|
|
1260
1257
|
const { addData, addConversion, getVisitorCode } = this.props;
|
|
1261
1258
|
const visitorCode = getVisitorCode('example.com');
|
|
1262
1259
|
|
|
1263
|
-
addData(visitorCode,
|
|
1260
|
+
addData(visitorCode, addConversion(32, 10, false));
|
|
1264
1261
|
}
|
|
1265
1262
|
|
|
1266
1263
|
...
|
|
@@ -1305,7 +1302,7 @@ function MyComponent(): JSX.Element {
|
|
|
1305
1302
|
useEffect(() => {
|
|
1306
1303
|
const visitorCode = getVisitorCode('example.com');
|
|
1307
1304
|
|
|
1308
|
-
addData(visitorCode,
|
|
1305
|
+
addData(visitorCode, addCustomData(1, 'some custom value'));
|
|
1309
1306
|
}, []);
|
|
1310
1307
|
|
|
1311
1308
|
...
|
|
@@ -1333,7 +1330,7 @@ class MyComponent extends React.Component {
|
|
|
1333
1330
|
const { addData, addCustomData, getVisitorCode } = this.props;
|
|
1334
1331
|
const visitorCode = getVisitorCode('example.com');
|
|
1335
1332
|
|
|
1336
|
-
addData(visitorCode,
|
|
1333
|
+
addData(visitorCode, addCustomData(1, 'some custom value'));
|
|
1337
1334
|
}
|
|
1338
1335
|
|
|
1339
1336
|
...
|
|
@@ -1346,43 +1343,44 @@ export default compose(
|
|
|
1346
1343
|
)(MyComponent);
|
|
1347
1344
|
```
|
|
1348
1345
|
|
|
1349
|
-
##
|
|
1350
|
-
A callback function `
|
|
1346
|
+
## Device
|
|
1347
|
+
A callback function `addDevice()` adds device.
|
|
1351
1348
|
|
|
1352
|
-
#### `
|
|
1349
|
+
#### `addDevice`
|
|
1353
1350
|
##### Arguments
|
|
1354
|
-
- `
|
|
1351
|
+
- `device: DeviceType` - device type: Phone, Tablet, Desktop.
|
|
1352
|
+
|
|
1355
1353
|
|
|
1356
1354
|
##### Returns
|
|
1357
|
-
- An instance of `
|
|
1355
|
+
- An instance of `Device: IDevice`.
|
|
1358
1356
|
|
|
1359
|
-
### `
|
|
1357
|
+
### `useDevice`
|
|
1360
1358
|
#### Returns
|
|
1361
|
-
- A callback function `
|
|
1359
|
+
- A callback function `addDevice()`.
|
|
1362
1360
|
|
|
1363
1361
|
#### Example
|
|
1364
1362
|
```jsx
|
|
1365
1363
|
import { useEffect } from 'react';
|
|
1366
|
-
import { useAddData,
|
|
1364
|
+
import { useAddData, useDevice, DeviceType, useVisitorCode } from '@kameleoon/react-sdk';
|
|
1367
1365
|
|
|
1368
1366
|
function MyComponent(): JSX.Element {
|
|
1369
1367
|
const { addData } = useAddData();
|
|
1370
1368
|
const { getVisitorCode } = useVisitorCode();
|
|
1371
|
-
const {
|
|
1369
|
+
const { addDevice } = useDevice();
|
|
1372
1370
|
|
|
1373
1371
|
useEffect(() => {
|
|
1374
1372
|
const visitorCode = getVisitorCode('example.com');
|
|
1375
1373
|
|
|
1376
|
-
addData(visitorCode,
|
|
1374
|
+
addData(visitorCode, addDevice(DeviceType.Desktop));
|
|
1377
1375
|
}, []);
|
|
1378
1376
|
|
|
1379
1377
|
...
|
|
1380
1378
|
}
|
|
1381
1379
|
```
|
|
1382
1380
|
|
|
1383
|
-
### `
|
|
1381
|
+
### `withDevice`
|
|
1384
1382
|
#### Arguments
|
|
1385
|
-
- `Component: React.Component` - component which will be enhanced with the prop `
|
|
1383
|
+
- `Component: React.Component` - component which will be enhanced with the prop `addDevice()`.
|
|
1386
1384
|
|
|
1387
1385
|
#### Returns
|
|
1388
1386
|
- A wrapped component with additional props as described above.
|
|
@@ -1392,16 +1390,17 @@ function MyComponent(): JSX.Element {
|
|
|
1392
1390
|
import {
|
|
1393
1391
|
withVisitorCode,
|
|
1394
1392
|
withAddData,
|
|
1395
|
-
|
|
1393
|
+
withDevice,
|
|
1394
|
+
DeviceType,
|
|
1396
1395
|
compose,
|
|
1397
1396
|
} from '@kameleoon/react-sdk';
|
|
1398
1397
|
|
|
1399
1398
|
class MyComponent extends React.Component {
|
|
1400
1399
|
componentDidMount() {
|
|
1401
|
-
const { addData,
|
|
1400
|
+
const { addData, addDevice, getVisitorCode } = this.props;
|
|
1402
1401
|
const visitorCode = getVisitorCode('example.com');
|
|
1403
1402
|
|
|
1404
|
-
addData(visitorCode,
|
|
1403
|
+
addData(visitorCode, addDevice(DeviceType.Desktop));
|
|
1405
1404
|
}
|
|
1406
1405
|
|
|
1407
1406
|
...
|
|
@@ -1409,7 +1408,7 @@ class MyComponent extends React.Component {
|
|
|
1409
1408
|
|
|
1410
1409
|
export default compose(
|
|
1411
1410
|
withAddData,
|
|
1412
|
-
|
|
1411
|
+
withDevice,
|
|
1413
1412
|
withVisitorCode,
|
|
1414
1413
|
)(MyComponent);
|
|
1415
1414
|
```
|
|
@@ -1441,4 +1440,4 @@ class MyComponent extends React.Component {
|
|
|
1441
1440
|
}
|
|
1442
1441
|
|
|
1443
1442
|
export default compose(withVisitorCode, withTriggerExperiment)(MyComponent);
|
|
1444
|
-
```
|
|
1443
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { KameleoonContext } from './KameleoonContext';
|
|
2
2
|
export { KAMELEOON_SDK_LOCAL_STORAGE_KEY, Browser, KameleoonException, } from './constants';
|
|
3
|
-
export { Browser as IBrowser, Conversion as IConversion,
|
|
3
|
+
export { Browser as IBrowser, Conversion as IConversion, Device as IDevice, PageView as IPageView, DeviceType, } from 'kameleoon-client-javascript/dist/data';
|
|
4
4
|
export { default as compose } from './compose';
|
|
5
5
|
export { default as KameleoonProvider } from './KameleoonProvider';
|
|
6
6
|
export * from './types';
|
|
@@ -21,7 +21,7 @@ export { useBrowser } from './useBrowser';
|
|
|
21
21
|
export { usePageView } from './usePageView';
|
|
22
22
|
export { useConversion } from './useConversion';
|
|
23
23
|
export { useCustomData } from './useCustomData';
|
|
24
|
-
export {
|
|
24
|
+
export { useDevice } from './useDevice';
|
|
25
25
|
export { useRunWhenReady } from './useRunWhenReady';
|
|
26
26
|
export { withKameleoon } from './withKameleoon';
|
|
27
27
|
export { withFeature } from './withFeature';
|
|
@@ -35,8 +35,8 @@ export { withTrackingConversion } from './withTrackingConversion';
|
|
|
35
35
|
export { withAddData } from './withAddData';
|
|
36
36
|
export { withFlush } from './withFlush';
|
|
37
37
|
export { withBrowser } from './withBrowser';
|
|
38
|
+
export { withDevice } from './withDevice';
|
|
38
39
|
export { withPageView } from './withPageView';
|
|
39
40
|
export { withConversion } from './withConversion';
|
|
40
41
|
export { withCustomData } from './withCustomData';
|
|
41
|
-
export { withInterest } from './withInterest';
|
|
42
42
|
export { withRunWhenReady } from './withRunWhenReady';
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.withRunWhenReady = exports.
|
|
16
|
+
exports.withRunWhenReady = exports.withCustomData = exports.withConversion = exports.withPageView = exports.withDevice = exports.withBrowser = exports.withFlush = exports.withAddData = exports.withTrackingConversion = exports.withFeatureVariable = exports.withRetrieveDataFromRemoteSource = exports.withVariationAssociatedData = exports.withActivateFeature = exports.withTriggerExperiment = exports.withVisitorCode = exports.withFeature = exports.withKameleoon = exports.useRunWhenReady = exports.useDevice = exports.useCustomData = exports.useConversion = exports.usePageView = exports.useBrowser = exports.useFlush = exports.useAddData = exports.useRetrieveDataFromRemoteSource = exports.useTrackingConversion = exports.useFeatureVariable = exports.useVariationAssociatedData = exports.useActivateFeature = exports.useTriggerExperiment = exports.useVisitorCode = exports.useFeature = exports.useKameleoon = exports.Feature = exports.createClient = exports.KameleoonProvider = exports.compose = exports.DeviceType = exports.IPageView = exports.IDevice = exports.IConversion = exports.IBrowser = exports.KameleoonException = exports.Browser = exports.KAMELEOON_SDK_LOCAL_STORAGE_KEY = exports.KameleoonContext = void 0;
|
|
17
17
|
var KameleoonContext_1 = require("./KameleoonContext");
|
|
18
18
|
Object.defineProperty(exports, "KameleoonContext", { enumerable: true, get: function () { return KameleoonContext_1.KameleoonContext; } });
|
|
19
19
|
var constants_1 = require("./constants");
|
|
@@ -23,8 +23,9 @@ Object.defineProperty(exports, "KameleoonException", { enumerable: true, get: fu
|
|
|
23
23
|
var data_1 = require("kameleoon-client-javascript/dist/data");
|
|
24
24
|
Object.defineProperty(exports, "IBrowser", { enumerable: true, get: function () { return data_1.Browser; } });
|
|
25
25
|
Object.defineProperty(exports, "IConversion", { enumerable: true, get: function () { return data_1.Conversion; } });
|
|
26
|
-
Object.defineProperty(exports, "
|
|
26
|
+
Object.defineProperty(exports, "IDevice", { enumerable: true, get: function () { return data_1.Device; } });
|
|
27
27
|
Object.defineProperty(exports, "IPageView", { enumerable: true, get: function () { return data_1.PageView; } });
|
|
28
|
+
Object.defineProperty(exports, "DeviceType", { enumerable: true, get: function () { return data_1.DeviceType; } });
|
|
28
29
|
var compose_1 = require("./compose");
|
|
29
30
|
Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return __importDefault(compose_1).default; } });
|
|
30
31
|
var KameleoonProvider_1 = require("./KameleoonProvider");
|
|
@@ -64,8 +65,8 @@ var useConversion_1 = require("./useConversion");
|
|
|
64
65
|
Object.defineProperty(exports, "useConversion", { enumerable: true, get: function () { return useConversion_1.useConversion; } });
|
|
65
66
|
var useCustomData_1 = require("./useCustomData");
|
|
66
67
|
Object.defineProperty(exports, "useCustomData", { enumerable: true, get: function () { return useCustomData_1.useCustomData; } });
|
|
67
|
-
var
|
|
68
|
-
Object.defineProperty(exports, "
|
|
68
|
+
var useDevice_1 = require("./useDevice");
|
|
69
|
+
Object.defineProperty(exports, "useDevice", { enumerable: true, get: function () { return useDevice_1.useDevice; } });
|
|
69
70
|
var useRunWhenReady_1 = require("./useRunWhenReady");
|
|
70
71
|
Object.defineProperty(exports, "useRunWhenReady", { enumerable: true, get: function () { return useRunWhenReady_1.useRunWhenReady; } });
|
|
71
72
|
var withKameleoon_1 = require("./withKameleoon");
|
|
@@ -92,14 +93,14 @@ var withFlush_1 = require("./withFlush");
|
|
|
92
93
|
Object.defineProperty(exports, "withFlush", { enumerable: true, get: function () { return withFlush_1.withFlush; } });
|
|
93
94
|
var withBrowser_1 = require("./withBrowser");
|
|
94
95
|
Object.defineProperty(exports, "withBrowser", { enumerable: true, get: function () { return withBrowser_1.withBrowser; } });
|
|
96
|
+
var withDevice_1 = require("./withDevice");
|
|
97
|
+
Object.defineProperty(exports, "withDevice", { enumerable: true, get: function () { return withDevice_1.withDevice; } });
|
|
95
98
|
var withPageView_1 = require("./withPageView");
|
|
96
99
|
Object.defineProperty(exports, "withPageView", { enumerable: true, get: function () { return withPageView_1.withPageView; } });
|
|
97
100
|
var withConversion_1 = require("./withConversion");
|
|
98
101
|
Object.defineProperty(exports, "withConversion", { enumerable: true, get: function () { return withConversion_1.withConversion; } });
|
|
99
102
|
var withCustomData_1 = require("./withCustomData");
|
|
100
103
|
Object.defineProperty(exports, "withCustomData", { enumerable: true, get: function () { return withCustomData_1.withCustomData; } });
|
|
101
|
-
var withInterest_1 = require("./withInterest");
|
|
102
|
-
Object.defineProperty(exports, "withInterest", { enumerable: true, get: function () { return withInterest_1.withInterest; } });
|
|
103
104
|
var withRunWhenReady_1 = require("./withRunWhenReady");
|
|
104
105
|
Object.defineProperty(exports, "withRunWhenReady", { enumerable: true, get: function () { return withRunWhenReady_1.withRunWhenReady; } });
|
|
105
106
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,yCAIqB;AAHnB,4HAAA,+BAA+B,OAAA;AAC/B,oGAAA,OAAO,OAAA;AACP,+GAAA,kBAAkB,OAAA;AAEpB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,yCAI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AA,eAAe,OAAA;AACxB,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,6EAA4E;AAAnE,0IAAA,2BAA2B,OAAA;AACpC,uFAAsF;AAA7E,oJAAA,gCAAgC,OAAA;AACzC,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA"}
|
|
@@ -4,7 +4,7 @@ interface ActivateFeatureHookResult {
|
|
|
4
4
|
* @param visitorCode - unique identifier of the user
|
|
5
5
|
* @param featureKey - unique identifier or key of the feature you want to expose to a user
|
|
6
6
|
*/
|
|
7
|
-
hasFeature: (
|
|
7
|
+
hasFeature: (featureKey: string | number, visitorCode?: string) => boolean;
|
|
8
8
|
error: KameleoonError | null;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
@@ -5,28 +5,33 @@ var react_1 = require("react");
|
|
|
5
5
|
var useKameleoon_1 = require("./useKameleoon");
|
|
6
6
|
var ProviderError_1 = require("./ProviderError");
|
|
7
7
|
var useError_1 = require("./useError");
|
|
8
|
+
var useVisitorCode_1 = require("./useVisitorCode");
|
|
8
9
|
/**
|
|
9
10
|
* A React Hook that returns callback function which activates a feature toggle
|
|
10
11
|
*/
|
|
11
12
|
function useActivateFeature() {
|
|
12
13
|
var client = (0, useKameleoon_1.useKameleoon)().client;
|
|
13
14
|
var _a = (0, useError_1.useError)(), error = _a.error, setError = _a.setError;
|
|
14
|
-
var
|
|
15
|
+
var getVisitorCode = (0, useVisitorCode_1.useVisitorCode)().getVisitorCode;
|
|
16
|
+
var hasFeature = (0, react_1.useCallback)(function (featureKey, visitorCode) {
|
|
15
17
|
try {
|
|
16
|
-
|
|
18
|
+
var userCode = visitorCode !== null && visitorCode !== void 0 ? visitorCode : getVisitorCode('');
|
|
19
|
+
return client.activateFeature(userCode, featureKey);
|
|
17
20
|
}
|
|
18
21
|
catch (unknownError) {
|
|
19
22
|
setError(unknownError);
|
|
20
23
|
return false;
|
|
21
24
|
}
|
|
22
|
-
}, [client, setError]);
|
|
25
|
+
}, [client, getVisitorCode, setError]);
|
|
23
26
|
if (!client) {
|
|
24
27
|
throw new ProviderError_1.ProviderError('useActivateFeature');
|
|
25
28
|
}
|
|
26
|
-
return {
|
|
29
|
+
return (0, react_1.useMemo)(function () { return ({
|
|
27
30
|
hasFeature: hasFeature,
|
|
28
31
|
error: error,
|
|
29
|
-
};
|
|
32
|
+
}); },
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
+
[hasFeature]);
|
|
30
35
|
}
|
|
31
36
|
exports.useActivateFeature = useActivateFeature;
|
|
32
37
|
//# sourceMappingURL=useActivateFeature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActivateFeature.js","sourceRoot":"","sources":["../src/useActivateFeature.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"useActivateFeature.js","sourceRoot":"","sources":["../src/useActivateFeature.ts"],"names":[],"mappings":";;;AAAA,+BAA6C;AAC7C,+CAA8C;AAC9C,iDAAgD;AAEhD,uCAAsC;AACtC,mDAAkD;AAWlD;;GAEG;AACH,SAAgB,kBAAkB;IACxB,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAC5B,IAAA,KAAsB,IAAA,mBAAQ,GAAE,EAA9B,KAAK,WAAA,EAAE,QAAQ,cAAe,CAAC;IAC/B,IAAA,cAAc,GAAK,IAAA,+BAAc,GAAE,eAArB,CAAsB;IAE5C,IAAM,UAAU,GAAG,IAAA,mBAAW,EAC5B,UAAC,UAA2B,EAAE,WAAoB;QAChD,IAAI;YACF,IAAM,QAAQ,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,cAAc,CAAC,EAAE,CAAC,CAAC;YAEnD,OAAO,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;SACrD;QAAC,OAAO,YAAY,EAAE;YACrB,QAAQ,CAAC,YAAY,CAAC,CAAC;YAEvB,OAAO,KAAK,CAAC;SACd;IACH,CAAC,EACD,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,CAAC,CACnC,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,6BAAa,CAAC,oBAAoB,CAAC,CAAC;KAC/C;IAED,OAAO,IAAA,eAAO,EACZ,cAAM,OAAA,CAAC;QACL,UAAU,YAAA;QACV,KAAK,OAAA;KACN,CAAC,EAHI,CAGJ;IACF,uDAAuD;IACvD,CAAC,UAAU,CAAC,CACb,CAAC;AACJ,CAAC;AAhCD,gDAgCC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Device as IDevice, DeviceType } from 'kameleoon-client-javascript/dist/data';
|
|
2
|
+
interface DeviceHookResult {
|
|
3
|
+
/**
|
|
4
|
+
* @param device - device type: Phone, Tablet, Desktop
|
|
5
|
+
*/
|
|
6
|
+
addDevice: (device: DeviceType) => IDevice;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A React Hook that returns a callback function which adds interest
|
|
10
|
+
*/
|
|
11
|
+
export declare function useDevice(): DeviceHookResult;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDevice = 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 a callback function which adds interest
|
|
8
|
+
*/
|
|
9
|
+
function useDevice() {
|
|
10
|
+
var addDevice = (0, react_1.useCallback)(function (device) { return new kameleoon_client_javascript_1.KameleoonData.Device(device); }, []);
|
|
11
|
+
return {
|
|
12
|
+
addDevice: addDevice,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.useDevice = useDevice;
|
|
16
|
+
//# sourceMappingURL=useDevice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDevice.js","sourceRoot":"","sources":["../src/useDevice.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,2EAA4D;AAa5D;;GAEG;AACH,SAAgB,SAAS;IACvB,IAAM,SAAS,GAAG,IAAA,mBAAW,EAC3B,UAAC,MAAkB,IAAc,OAAA,IAAI,2CAAa,CAAC,MAAM,CAAC,MAAM,CAAC,EAAhC,CAAgC,EACjE,EAAE,CACH,CAAC;IAEF,OAAO;QACL,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AATD,8BASC"}
|
package/dist/useFeature.js
CHANGED
|
@@ -82,7 +82,7 @@ function useFeature(_a) {
|
|
|
82
82
|
var currentEnvironment = (_d = (_c = featureFlag === null || featureFlag === void 0 ? void 0 : featureFlag.environment) === null || _c === void 0 ? void 0 : _c.key) !== null && _d !== void 0 ? _d : constants_1.PRODUCTION;
|
|
83
83
|
try {
|
|
84
84
|
setFeature((_a = {},
|
|
85
|
-
_a[constants_1.FeatureResultField.IsActive] = hasFeature(
|
|
85
|
+
_a[constants_1.FeatureResultField.IsActive] = hasFeature(featureKey, userCode),
|
|
86
86
|
_a[constants_1.FeatureResultField.Variables] = getVariablesArray(currentEnvironment),
|
|
87
87
|
_a));
|
|
88
88
|
}
|
package/dist/useFeature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|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AE5D,OAAO,EAAE,OAAO,SAAA,EAAE,MAAM,QAAA,EAAE,CAAC;AAC7B,CAAC;AAtFD,gCAsFC"}
|
|
@@ -21,10 +21,6 @@ function useFeatureVariable() {
|
|
|
21
21
|
if (typeof value === 'string' && (0, isJSON_1.default)(value)) {
|
|
22
22
|
return JSON.parse(value);
|
|
23
23
|
}
|
|
24
|
-
// JS SDK returns string instead of actual boolean therefore temporal fix
|
|
25
|
-
if (typeof value === 'string' && (value === 'True' || value === 'False')) {
|
|
26
|
-
return JSON.parse(value.toLowerCase());
|
|
27
|
-
}
|
|
28
24
|
return value;
|
|
29
25
|
}, []);
|
|
30
26
|
var getFeatureVariable = (0, react_1.useCallback)(function (featureKey, variableKey) {
|
|
@@ -36,10 +32,12 @@ function useFeatureVariable() {
|
|
|
36
32
|
return undefined;
|
|
37
33
|
}
|
|
38
34
|
}, [client, getProcessedVariable, setError]);
|
|
39
|
-
return {
|
|
35
|
+
return (0, react_1.useMemo)(function () { return ({
|
|
40
36
|
getFeatureVariable: getFeatureVariable,
|
|
41
37
|
error: error,
|
|
42
|
-
};
|
|
38
|
+
}); },
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
[getFeatureVariable]);
|
|
43
41
|
}
|
|
44
42
|
exports.useFeatureVariable = useFeatureVariable;
|
|
45
43
|
//# sourceMappingURL=useFeatureVariable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFeatureVariable.js","sourceRoot":"","sources":["../src/useFeatureVariable.ts"],"names":[],"mappings":";;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"useFeatureVariable.js","sourceRoot":"","sources":["../src/useFeatureVariable.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA6C;AAC7C,gEAA0C;AAC1C,+CAA8C;AAG9C,uCAAsC;AActC;;GAEG;AACH,SAAgB,kBAAkB;IACxB,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAC5B,IAAA,KAAsB,IAAA,mBAAQ,GAAE,EAA9B,KAAK,WAAA,EAAE,QAAQ,cAAe,CAAC;IAEvC,IAAM,oBAAoB,GAAG,IAAA,mBAAW,EAAC,UAAC,KAAK;QAC7C,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,SAAS,CAAC;SAClB;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,gBAAM,EAAC,KAAK,CAAC,EAAE;YAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC1B;QAED,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAM,kBAAkB,GAAG,IAAA,mBAAW,EACpC,UACE,UAA2B,EAC3B,WAAmB;QAEnB,IAAI;YACF,OAAO,oBAAoB,CACzB,MAAM,CAAC,qBAAqB,CAAC,UAAU,EAAE,WAAW,CAAC,CACtD,CAAC;SACH;QAAC,OAAO,YAAY,EAAE;YACrB,QAAQ,CAAC,YAAY,CAAC,CAAC;YAEvB,OAAO,SAAS,CAAC;SAClB;IACH,CAAC,EACD,CAAC,MAAM,EAAE,oBAAoB,EAAE,QAAQ,CAAC,CACzC,CAAC;IAEF,OAAO,IAAA,eAAO,EACZ,cAAM,OAAA,CAAC;QACL,kBAAkB,oBAAA;QAClB,KAAK,OAAA;KACN,CAAC,EAHI,CAGJ;IACF,uDAAuD;IACvD,CAAC,kBAAkB,CAAC,CACrB,CAAC;AACJ,CAAC;AA1CD,gDA0CC"}
|
|
@@ -23,10 +23,12 @@ function useTriggerExperiment() {
|
|
|
23
23
|
return DEFAULT_VARIATION_ID;
|
|
24
24
|
}
|
|
25
25
|
}, [client, setError]);
|
|
26
|
-
return {
|
|
26
|
+
return (0, react_1.useMemo)(function () { return ({
|
|
27
27
|
getVariationId: getVariationId,
|
|
28
28
|
error: error,
|
|
29
|
-
};
|
|
29
|
+
}); },
|
|
30
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
+
[getVariationId]);
|
|
30
32
|
}
|
|
31
33
|
exports.useTriggerExperiment = useTriggerExperiment;
|
|
32
34
|
//# sourceMappingURL=useTriggerExperiment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTriggerExperiment.js","sourceRoot":"","sources":["../src/useTriggerExperiment.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"useTriggerExperiment.js","sourceRoot":"","sources":["../src/useTriggerExperiment.ts"],"names":[],"mappings":";;;AAAA,+BAA6C;AAC7C,+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,IAAA,eAAO,EACZ,cAAM,OAAA,CAAC;QACL,cAAc,gBAAA;QACd,KAAK,OAAA;KACN,CAAC,EAHI,CAGJ;IACF,uDAAuD;IACvD,CAAC,cAAc,CAAC,CACjB,CAAC;AACJ,CAAC;AA1BD,oDA0BC"}
|
|
@@ -21,10 +21,12 @@ function useVariationAssociatedData() {
|
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
}, [client, setError]);
|
|
24
|
-
return {
|
|
24
|
+
return (0, react_1.useMemo)(function () { return ({
|
|
25
25
|
getVariationAssociatedData: getVariationAssociatedData,
|
|
26
26
|
error: error,
|
|
27
|
-
};
|
|
27
|
+
}); },
|
|
28
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
+
[getVariationAssociatedData]);
|
|
28
30
|
}
|
|
29
31
|
exports.useVariationAssociatedData = useVariationAssociatedData;
|
|
30
32
|
//# sourceMappingURL=useVariationAssociatedData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVariationAssociatedData.js","sourceRoot":"","sources":["../src/useVariationAssociatedData.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"useVariationAssociatedData.js","sourceRoot":"","sources":["../src/useVariationAssociatedData.ts"],"names":[],"mappings":";;;AAAA,+BAA6C;AAC7C,+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;IACF,OAAO,IAAA,eAAO,EACZ,cAAM,OAAA,CAAC;QACL,0BAA0B,4BAAA;QAC1B,KAAK,OAAA;KACN,CAAC,EAHI,CAGJ;IACF,uDAAuD;IACvD,CAAC,0BAA0B,CAAC,CAC7B,CAAC;AACJ,CAAC;AAxBD,gEAwBC"}
|
|
@@ -6,7 +6,7 @@ interface IWithHasFeature {
|
|
|
6
6
|
* @param visitorCode - unique identifier of the user
|
|
7
7
|
* @param featureKey - unique identifier or key of the feature you want to expose to a user
|
|
8
8
|
*/
|
|
9
|
-
hasFeature: (
|
|
9
|
+
hasFeature: (featureKey: string | number, visitorCode?: string) => boolean;
|
|
10
10
|
activateFeatureError: KameleoonError | null;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -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 {};
|
|
@@ -11,21 +11,19 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
14
|
+
exports.withDevice = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
var react_1 = require("react");
|
|
17
17
|
var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
|
|
18
18
|
/**
|
|
19
19
|
* A React HOC that gives a wrapped component access to callback function
|
|
20
|
-
* which adds
|
|
20
|
+
* which adds device type
|
|
21
21
|
*/
|
|
22
|
-
function
|
|
22
|
+
function withDevice(Component) {
|
|
23
23
|
return function WrappedComponent(props) {
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
}, []);
|
|
27
|
-
return (0, jsx_runtime_1.jsx)(Component, __assign({ addInterest: addInterest }, props), void 0);
|
|
24
|
+
var addDevice = (0, react_1.useCallback)(function (device) { return new kameleoon_client_javascript_1.KameleoonData.Device(device); }, []);
|
|
25
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ addDevice: addDevice }, props), void 0);
|
|
28
26
|
};
|
|
29
27
|
}
|
|
30
|
-
exports.
|
|
31
|
-
//# sourceMappingURL=
|
|
28
|
+
exports.withDevice = withDevice;
|
|
29
|
+
//# sourceMappingURL=withDevice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withDevice.js","sourceRoot":"","sources":["../src/withDevice.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAK3C,2EAA4D;AAU5D;;;GAGG;AACH,SAAgB,UAAU,CACxB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,SAAS,GAAG,IAAA,mBAAW,EAC3B,UAAC,MAAkB,IAAc,OAAA,IAAI,2CAAa,CAAC,MAAM,CAAC,MAAM,CAAC,EAAhC,CAAgC,EACjE,EAAE,CACH,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,SAAS,EAAE,SAAS,IAAO,KAAe,UAAI,CAAC;IACnE,CAAC,CAAC;AACJ,CAAC;AAXD,gCAWC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kameleoon/react-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Kameleoon React SDK",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"start": "npm run clear && tsc -w",
|
|
12
12
|
"build": "npm run clear && tsc",
|
|
13
13
|
"deploy": "npm publish --tag latest --access public",
|
|
14
|
+
"deploy-nexus": "npm publish --registry=https://nexus.kameleoon.net/repository/npm-kameleoon/",
|
|
14
15
|
"release": "../../scripts/release.sh react-sdk",
|
|
15
16
|
"update-documentation": "../../scripts/update_documentation.sh react",
|
|
16
17
|
"test": "jest",
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
38
|
"@types/validator": "^13.6.3",
|
|
38
|
-
"kameleoon-client-javascript": "^1.0.
|
|
39
|
+
"kameleoon-client-javascript": "^1.0.9",
|
|
39
40
|
"validator": "^13.6.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|