@kameleoon/react-sdk 2.0.0 → 2.1.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 CHANGED
@@ -5,8 +5,16 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
5
5
 
6
6
  [Project Homepage](https://developers.kameleoon.com/react-js-sdk.html)
7
7
 
8
+ # 2.1.0 (2022-04-18)
9
+
10
+
11
+ ### Features
12
+
13
+ * retrieve data from remote source
14
+
8
15
  # 2.0.0 (2022-02-24)
9
16
 
17
+
10
18
  ### Features
11
19
 
12
20
  * add multi environment support
package/README.md CHANGED
@@ -435,9 +435,9 @@ export default compose(withVisitorCode, withActivateFeature)(MyComponent);
435
435
  ```
436
436
 
437
437
  ## Obtain variation associated data
438
- A callback function `getVariationAssociatedData()` which retrieves JSON data assiciated with a variation. The JSON data usually represents some metadata of the variation, and can be configured on our web application interface or via our Automation API.
438
+ A callback function `getVariationAssociatedData()` which retrieves JSON data associated with a variation. The JSON data usually represents some metadata of the variation, and can be configured on our web application interface or via our Automation API.
439
439
 
440
- This calllback function takes the `variationId` as a parameter and will return the data as a JavaScript object. It will throw an exception `(KameleoonException.VariationConfigurationNotFound)` if the `variationId` is wrong or corresponds to an experiment that is not yet online.
440
+ This callback function takes the `variationId` as a parameter and will return the data as a JavaScript object. It will throw an exception `(KameleoonException.VariationConfigurationNotFound)` if the `variationId` is wrong or corresponds to an experiment that is not yet online.
441
441
 
442
442
  #### Exceptions Thrown
443
443
  - `KameleoonException.VariationConfigurationNotFound` - Exception indicating that the requested variation ID has not been found in the internal configuration of the SDK. This is usually normal and means that the variation's corresponding experiment has not yet been activated on Kameleoon's side.
@@ -494,6 +494,74 @@ class MyComponent extends React.Component {
494
494
  export default withVariationAssociatedData(MyComponent);
495
495
  ```
496
496
 
497
+ ## Obtain data from remote source
498
+ An callback function `retrieveDataFromRemoteSource()` can be used to retrieve data using specific key and siteCode from Kameleoon provider. The Data is stored on a remote Kameleoon server. Usually data will be stored on our remote servers via the use of our Data API. This method, along with the availability of our highly scalable servers for this purpose, provides a convenient way to quickly store massive amounts of data that can be later retrieved for each of your visitors / users.
499
+
500
+ Note that since a server call is required, this mechanism is asynchronous, make sure to properly handle promise which will be returned from a function call.
501
+
502
+
503
+ #### Exceptions Thrown
504
+ - Local Error will be thrown if remote source data couldn't be accessed or retrieved data contains an empty JSON.
505
+
506
+ #### `retrieveDataFromRemoteSource()`
507
+
508
+ ##### Arguments
509
+ - `key: string` - unique key for the current siteCode used to store data on the remote source (can be created via `POST` request to Kameleoon Data API). This field is mandatory.
510
+
511
+ ##### Returns
512
+ - JSON object with the data posted to Kameleoon Data API.
513
+
514
+ #### Types
515
+ - `RemoteSourceDataType` can be used for handling data type.
516
+
517
+ ### `useRetrieveDataFromRemoteSource`
518
+ #### Returns
519
+ - A callback function `retrieveDataFromRemoteSource()`.
520
+
521
+ #### Example
522
+ ```jsx
523
+ import { useEffect, useCallback } from 'react';
524
+ import { useRetrieveDataFromRemoteSource, RemoteSourceDataType } from '@kameleoon/react-sdk';
525
+
526
+ function MyComponent(): JSX.Element {
527
+ const { retrieveDataFromRemoteSource } = useRetrieveDataFromRemoteSource();
528
+
529
+ const processRetrievedData = useCallback(async () => {
530
+ const data: RemoteSourceDataType = await retrieveDataFromRemoteSource('example-key');
531
+ // Your code
532
+ }, [retrieveDataFromRemoteSource]);
533
+
534
+ useEffect(() => {
535
+ processRetrievedData();
536
+ }, [processRetrievedData]);
537
+
538
+ ...
539
+ }
540
+ ```
541
+ ### `withRetrieveDataFromRemoteSource`
542
+ #### Arguments
543
+ - `Component: React.Component` - component which will be enhanced with the prop `retrieveDataFromRemoteSource()`.
544
+
545
+ #### Returns
546
+ - A wrapped component with additional props as described above.
547
+
548
+ #### Example
549
+ ```jsx
550
+ import { withRetrieveDataFromRemoteSource, RemoteSourceDataType } from '@kameleoon/react-sdk';
551
+
552
+ class MyComponent extends React.Component {
553
+ async componentDidMount() {
554
+ const { retrieveDataFromRemoteSource } = this.props;
555
+ const data: RemoteSourceDataType = await getVariationAssociatedData('example-key');
556
+ // Your code
557
+ }
558
+
559
+ ...
560
+ }
561
+
562
+ export default withRetrieveDataFromRemoteSource(MyComponent);
563
+ ```
564
+
497
565
  ## Obtain feature variable
498
566
  A callback function `getFeatureVariable()` which retrieves a feature variable.
499
567
 
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { KAMELEOON_SDK_LOCAL_STORAGE_KEY, Browser } from './constants';
3
3
  export { Browser as IBrowser, Conversion as IConversion, Interest as IInterest, PageView as IPageView, } from 'kameleoon-client-javascript/dist/data';
4
4
  export { default as compose } from './compose';
5
5
  export { default as KameleoonProvider } from './KameleoonProvider';
6
+ export * from './types';
6
7
  export { createClient } from './kameleoonClient';
7
8
  export { Feature } from './Feature';
8
9
  export { useKameleoon } from './useKameleoon';
@@ -13,6 +14,7 @@ export { useActivateFeature } from './useActivateFeature';
13
14
  export { useVariationAssociatedData } from './useVariationAssociatedData';
14
15
  export { useFeatureVariable } from './useFeatureVariable';
15
16
  export { useTrackingConversion } from './useTrackingConversion';
17
+ export { useRetrieveDataFromRemoteSource } from './useRetrieveDataFromRemoteSource';
16
18
  export { useAddData } from './useAddData';
17
19
  export { useFlush } from './useFlush';
18
20
  export { useBrowser } from './useBrowser';
@@ -26,6 +28,7 @@ export { withVisitorCode } from './withVisitorCode';
26
28
  export { withTriggerExperiment } from './withTriggerExperiment';
27
29
  export { withActivateFeature } from './withActivateFeature';
28
30
  export { withVariationAssociatedData } from './withVariationAssociatedData';
31
+ export { withRetrieveDataFromRemoteSource } from './withRetrieveDataFromRemoteSource';
29
32
  export { withFeatureVariable } from './withFeatureVariable';
30
33
  export { withTrackingConversion } from './withTrackingConversion';
31
34
  export { withAddData } from './withAddData';
package/dist/index.js CHANGED
@@ -1,9 +1,19 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
2
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
14
  };
5
15
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withInterest = exports.withCustomData = exports.withConversion = exports.withPageView = exports.withBrowser = exports.withFlush = exports.withAddData = exports.withTrackingConversion = exports.withFeatureVariable = exports.withVariationAssociatedData = exports.withActivateFeature = exports.withTriggerExperiment = exports.withVisitorCode = exports.withFeature = exports.withKameleoon = exports.useInterest = exports.useCustomData = exports.useConversion = exports.usePageView = exports.useBrowser = exports.useFlush = exports.useAddData = 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.IPageView = exports.IInterest = exports.IConversion = exports.IBrowser = exports.Browser = exports.KAMELEOON_SDK_LOCAL_STORAGE_KEY = exports.KameleoonContext = void 0;
16
+ exports.withInterest = exports.withCustomData = exports.withConversion = exports.withPageView = 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.useInterest = 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.IPageView = exports.IInterest = exports.IConversion = exports.IBrowser = exports.Browser = exports.KAMELEOON_SDK_LOCAL_STORAGE_KEY = exports.KameleoonContext = void 0;
7
17
  var KameleoonContext_1 = require("./KameleoonContext");
8
18
  Object.defineProperty(exports, "KameleoonContext", { enumerable: true, get: function () { return KameleoonContext_1.KameleoonContext; } });
9
19
  var constants_1 = require("./constants");
@@ -18,6 +28,7 @@ var compose_1 = require("./compose");
18
28
  Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return __importDefault(compose_1).default; } });
19
29
  var KameleoonProvider_1 = require("./KameleoonProvider");
20
30
  Object.defineProperty(exports, "KameleoonProvider", { enumerable: true, get: function () { return __importDefault(KameleoonProvider_1).default; } });
31
+ __exportStar(require("./types"), exports);
21
32
  var kameleoonClient_1 = require("./kameleoonClient");
22
33
  Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return kameleoonClient_1.createClient; } });
23
34
  var Feature_1 = require("./Feature");
@@ -38,6 +49,8 @@ var useFeatureVariable_1 = require("./useFeatureVariable");
38
49
  Object.defineProperty(exports, "useFeatureVariable", { enumerable: true, get: function () { return useFeatureVariable_1.useFeatureVariable; } });
39
50
  var useTrackingConversion_1 = require("./useTrackingConversion");
40
51
  Object.defineProperty(exports, "useTrackingConversion", { enumerable: true, get: function () { return useTrackingConversion_1.useTrackingConversion; } });
52
+ var useRetrieveDataFromRemoteSource_1 = require("./useRetrieveDataFromRemoteSource");
53
+ Object.defineProperty(exports, "useRetrieveDataFromRemoteSource", { enumerable: true, get: function () { return useRetrieveDataFromRemoteSource_1.useRetrieveDataFromRemoteSource; } });
41
54
  var useAddData_1 = require("./useAddData");
42
55
  Object.defineProperty(exports, "useAddData", { enumerable: true, get: function () { return useAddData_1.useAddData; } });
43
56
  var useFlush_1 = require("./useFlush");
@@ -64,6 +77,8 @@ var withActivateFeature_1 = require("./withActivateFeature");
64
77
  Object.defineProperty(exports, "withActivateFeature", { enumerable: true, get: function () { return withActivateFeature_1.withActivateFeature; } });
65
78
  var withVariationAssociatedData_1 = require("./withVariationAssociatedData");
66
79
  Object.defineProperty(exports, "withVariationAssociatedData", { enumerable: true, get: function () { return withVariationAssociatedData_1.withVariationAssociatedData; } });
80
+ var withRetrieveDataFromRemoteSource_1 = require("./withRetrieveDataFromRemoteSource");
81
+ Object.defineProperty(exports, "withRetrieveDataFromRemoteSource", { enumerable: true, get: function () { return withRetrieveDataFromRemoteSource_1.withRetrieveDataFromRemoteSource; } });
67
82
  var withFeatureVariable_1 = require("./withFeatureVariable");
68
83
  Object.defineProperty(exports, "withFeatureVariable", { enumerable: true, get: function () { return withFeatureVariable_1.withFeatureVariable; } });
69
84
  var withTrackingConversion_1 = require("./withTrackingConversion");
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,yCAAuE;AAA9D,4HAAA,+BAA+B,OAAA;AAAE,oGAAA,OAAO,OAAA;AACjD,8DAK+C;AAJ7C,gGAAA,OAAO,OAAY;AACnB,mGAAA,UAAU,OAAe;AACzB,iGAAA,QAAQ,OAAa;AACrB,iGAAA,QAAQ,OAAa;AAEvB,qCAA+C;AAAtC,mHAAA,OAAO,OAAW;AAC3B,yDAAmE;AAA1D,uIAAA,OAAO,OAAqB;AACrC,qDAAiD;AAAxC,+GAAA,YAAY,OAAA;AACrB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,2DAA0D;AAAjD,wHAAA,kBA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AAA,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,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { KameleoonClient } from 'kameleoon-client-javascript';
3
3
  import { DataInterface } from 'kameleoon-client-javascript/dist/interfaces/interfaces';
4
- import { AnyType, IFeature } from '../types';
4
+ import { AnyType, IFeature, RemoteSourceDataType } from '../types';
5
5
  import { IBrowser, IConversion, IInterest, IPageView, Browser } from '..';
6
6
  export interface IFormProps {
7
7
  client?: KameleoonClient;
@@ -15,8 +15,9 @@ export interface IFormProps {
15
15
  addInterest?: (index: number) => IInterest;
16
16
  addConversion?: (goalId: number, revenue?: number, negative?: boolean) => IConversion;
17
17
  getVariationAssociatedData?: (variationId: number) => AnyType;
18
+ retrieveDataFromRemoteSource?: (key: string) => Promise<RemoteSourceDataType>;
18
19
  getVariationId?: (visitorCode: string, experimentId: number) => number;
19
20
  }
20
- declare function Form({ client, feature, isRenderProps, getVisitorCode, hasFeature, addData, addBrowser, addPageView, addInterest, addConversion, getVariationAssociatedData, getVariationId, }: IFormProps): JSX.Element;
21
+ declare function Form({ client, feature, isRenderProps, getVisitorCode, hasFeature, addData, addBrowser, addPageView, addInterest, addConversion, getVariationAssociatedData, retrieveDataFromRemoteSource, getVariationId, }: IFormProps): JSX.Element;
21
22
  declare const _default: React.MemoExoticComponent<typeof Form>;
22
23
  export default _default;
@@ -10,6 +10,42 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
13
49
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
51
  };
@@ -21,39 +57,16 @@ var constants_1 = require("./constants");
21
57
  var constants_2 = require("../constants");
22
58
  var __1 = require("..");
23
59
  function Form(_a) {
60
+ var _this = this;
24
61
  var _b, _c, _d, _e, _f;
25
- var client = _a.client, feature = _a.feature, isRenderProps = _a.isRenderProps, getVisitorCode = _a.getVisitorCode, hasFeature = _a.hasFeature, addData = _a.addData, addBrowser = _a.addBrowser, addPageView = _a.addPageView, addInterest = _a.addInterest, addConversion = _a.addConversion, getVariationAssociatedData = _a.getVariationAssociatedData, getVariationId = _a.getVariationId;
62
+ var client = _a.client, feature = _a.feature, isRenderProps = _a.isRenderProps, getVisitorCode = _a.getVisitorCode, hasFeature = _a.hasFeature, addData = _a.addData, addBrowser = _a.addBrowser, addPageView = _a.addPageView, addInterest = _a.addInterest, addConversion = _a.addConversion, getVariationAssociatedData = _a.getVariationAssociatedData, retrieveDataFromRemoteSource = _a.retrieveDataFromRemoteSource, getVariationId = _a.getVariationId;
26
63
  var _g = (0, react_1.useState)(''), visitorCode = _g[0], setVisitorCode = _g[1];
27
64
  var _h = (0, react_1.useState)(false), featureFlag = _h[0], setFeatureFlag = _h[1];
28
65
  var _j = (0, react_1.useState)([]), featureVariables = _j[0], setFeatureVariables = _j[1];
29
66
  var _k = (0, react_1.useState)([]), customData = _k[0], setCustomData = _k[1];
30
67
  var _l = (0, react_1.useState)(), variationId = _l[0], setVariationId = _l[1];
31
68
  var _m = (0, react_1.useState)(), variationData = _m[0], setVariationData = _m[1];
32
- (0, react_1.useEffect)(function () {
33
- if (!isRenderProps && getVariationId) {
34
- setVariationId(getVariationId(constants_1.USER_ID, constants_1.EXPERIMENT_ID));
35
- }
36
- }, [getVariationId, isRenderProps]);
37
- (0, react_1.useEffect)(function () {
38
- if (variationId && getVariationAssociatedData) {
39
- setVariationData(getVariationAssociatedData(variationId));
40
- }
41
- }, [getVariationAssociatedData, variationId]);
42
- (0, react_1.useEffect)(function () {
43
- if (getVisitorCode) {
44
- setVisitorCode(getVisitorCode(constants_1.KAMELEOON_URL));
45
- }
46
- }, [getVisitorCode]);
47
- (0, react_1.useEffect)(function () {
48
- if (hasFeature) {
49
- setFeatureFlag(hasFeature(constants_1.USER_ID, constants_1.FEATURE_KEY));
50
- }
51
- }, [hasFeature]);
52
- (0, react_1.useEffect)(function () {
53
- if (feature.variables) {
54
- setFeatureVariables(feature.variables);
55
- }
56
- }, [feature, isRenderProps]);
69
+ var _o = (0, react_1.useState)(null), remoteSourceData = _o[0], setRemoteSourceData = _o[1];
57
70
  function displayCustomData() {
58
71
  var kameleoonConfig = localStorage.getItem(constants_2.KAMELEOON_SDK_LOCAL_STORAGE_KEY);
59
72
  if (kameleoonConfig && visitorCode) {
@@ -89,7 +102,50 @@ function Form(_a) {
89
102
  displayCustomData();
90
103
  }
91
104
  }
92
- return ((0, jsx_runtime_1.jsxs)("form", { children: [(0, jsx_runtime_1.jsx)("h1", { children: "Feature flag activation test" }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Always active", isActive: true }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active only when feature flag is on", isActive: isRenderProps ? feature.isActive : featureFlag }, void 0), !isRenderProps && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active only when kameleoon client is connected", isActive: Boolean(client) }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active only when visitor code is present", isActive: Boolean(visitorCode) }, void 0)] }, void 0)), (0, jsx_runtime_1.jsx)("h1", { children: "Feature flag variables test" }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when string variable is present", isActive: Boolean((_b = featureVariables[0]) === null || _b === void 0 ? void 0 : _b[constants_1.FeatureVariables.STRING]) }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when boolean variable is present", isActive: Boolean((_c = featureVariables[1]) === null || _c === void 0 ? void 0 : _c[constants_1.FeatureVariables.BOOLEAN]) }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when number variable is present", isActive: Boolean((_d = featureVariables[2]) === null || _d === void 0 ? void 0 : _d[constants_1.FeatureVariables.NUMBER]) }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when JSON variable is present", isActive: Boolean((_e = featureVariables[3]) === null || _e === void 0 ? void 0 : _e[constants_1.FeatureVariables.JSON]) }, void 0), (0, jsx_runtime_1.jsx)("h1", { children: "Multi Environment test" }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active only when client environment option is set to value different from the default 'production' (variables above will become inactive), make sure to disable other stories and clear local storage, as for now client is not capable of handling several environments simultaneously", isActive: Boolean((_f = featureVariables[0]) === null || _f === void 0 ? void 0 : _f[constants_1.FeatureVariables.MULTI_ENVIRONMENT]) }, void 0), !isRenderProps && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h1", { children: "Feature flag associated variation test" }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when experiment is triggered", isActive: Boolean(variationId) }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when variationData is present", isActive: Boolean(variationData) }, void 0), (0, jsx_runtime_1.jsx)("h1", { children: "Feature flag custom data test" }, void 0), (0, jsx_runtime_1.jsx)("br", {}, void 0), (0, jsx_runtime_1.jsx)("button", __assign({ type: "button", onClick: handleAddBrowser }, { children: "Add browser data" }), void 0), (0, jsx_runtime_1.jsx)("button", __assign({ type: "button", onClick: handleAddPageView }, { children: "Add page view data" }), void 0), (0, jsx_runtime_1.jsx)("button", __assign({ type: "button", onClick: handleAddInterest }, { children: "Add interest data" }), void 0), (0, jsx_runtime_1.jsx)("button", __assign({ type: "button", onClick: handleAddConversion }, { children: "Add conversion data" }), void 0), (0, jsx_runtime_1.jsx)("p", { children: "Custom data:" }, void 0), customData.map(function (item, index) {
105
+ var processRetrievedData = (0, react_1.useCallback)(function () { return __awaiter(_this, void 0, void 0, function () {
106
+ var data;
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0:
110
+ if (!retrieveDataFromRemoteSource) return [3 /*break*/, 2];
111
+ return [4 /*yield*/, retrieveDataFromRemoteSource(constants_1.KAMELEOON_VISITOR_KEY)];
112
+ case 1:
113
+ data = _a.sent();
114
+ setRemoteSourceData(data);
115
+ _a.label = 2;
116
+ case 2: return [2 /*return*/];
117
+ }
118
+ });
119
+ }); }, [retrieveDataFromRemoteSource]);
120
+ (0, react_1.useEffect)(function () {
121
+ if (!isRenderProps && getVariationId) {
122
+ setVariationId(getVariationId(constants_1.USER_ID, constants_1.EXPERIMENT_ID));
123
+ }
124
+ }, [getVariationId, isRenderProps]);
125
+ (0, react_1.useEffect)(function () {
126
+ if (variationId && getVariationAssociatedData) {
127
+ setVariationData(getVariationAssociatedData(variationId));
128
+ }
129
+ }, [getVariationAssociatedData, variationId]);
130
+ (0, react_1.useEffect)(function () {
131
+ if (getVisitorCode) {
132
+ setVisitorCode(getVisitorCode(constants_1.KAMELEOON_URL));
133
+ }
134
+ }, [getVisitorCode]);
135
+ (0, react_1.useEffect)(function () {
136
+ if (hasFeature) {
137
+ setFeatureFlag(hasFeature(constants_1.USER_ID, constants_1.FEATURE_KEY));
138
+ }
139
+ }, [hasFeature]);
140
+ (0, react_1.useEffect)(function () {
141
+ if (feature.variables) {
142
+ setFeatureVariables(feature.variables);
143
+ }
144
+ }, [feature, isRenderProps]);
145
+ (0, react_1.useEffect)(function () {
146
+ processRetrievedData();
147
+ }, [processRetrievedData]);
148
+ return ((0, jsx_runtime_1.jsxs)("form", { children: [(0, jsx_runtime_1.jsx)("h1", { children: "Feature flag activation test" }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Always active", isActive: true }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active only when feature flag is on", isActive: isRenderProps ? feature.isActive : featureFlag }, void 0), !isRenderProps && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active only when kameleoon client is connected", isActive: Boolean(client) }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active only when visitor code is present", isActive: Boolean(visitorCode) }, void 0)] }, void 0)), (0, jsx_runtime_1.jsx)("h1", { children: "Feature flag variables test" }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when string variable is present", isActive: Boolean((_b = featureVariables[0]) === null || _b === void 0 ? void 0 : _b[constants_1.FeatureVariables.STRING]) }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when boolean variable is present", isActive: Boolean((_c = featureVariables[1]) === null || _c === void 0 ? void 0 : _c[constants_1.FeatureVariables.BOOLEAN]) }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when number variable is present", isActive: Boolean((_d = featureVariables[2]) === null || _d === void 0 ? void 0 : _d[constants_1.FeatureVariables.NUMBER]) }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when JSON variable is present", isActive: Boolean((_e = featureVariables[3]) === null || _e === void 0 ? void 0 : _e[constants_1.FeatureVariables.JSON]) }, void 0), (0, jsx_runtime_1.jsx)("h1", { children: "Multi Environment test" }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active only when client environment option is set to value different from the default 'production' (variables above will become inactive), make sure to disable other stories and clear local storage, as for now client is not capable of handling several environments simultaneously", isActive: Boolean((_f = featureVariables[0]) === null || _f === void 0 ? void 0 : _f[constants_1.FeatureVariables.MULTI_ENVIRONMENT]) }, void 0), (0, jsx_runtime_1.jsx)("h1", { children: "Remote Source Data test" }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when data from the remote was received and it's not empty", isActive: Boolean(remoteSourceData) }, void 0), !isRenderProps && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h1", { children: "Feature flag associated variation test" }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when experiment is triggered", isActive: Boolean(variationId) }, void 0), (0, jsx_runtime_1.jsx)(Radio_1.default, { title: "Active when variationData is present", isActive: Boolean(variationData) }, void 0), (0, jsx_runtime_1.jsx)("h1", { children: "Feature flag custom data test" }, void 0), (0, jsx_runtime_1.jsx)("br", {}, void 0), (0, jsx_runtime_1.jsx)("button", __assign({ type: "button", onClick: handleAddBrowser }, { children: "Add browser data" }), void 0), (0, jsx_runtime_1.jsx)("button", __assign({ type: "button", onClick: handleAddPageView }, { children: "Add page view data" }), void 0), (0, jsx_runtime_1.jsx)("button", __assign({ type: "button", onClick: handleAddInterest }, { children: "Add interest data" }), void 0), (0, jsx_runtime_1.jsx)("button", __assign({ type: "button", onClick: handleAddConversion }, { children: "Add conversion data" }), void 0), (0, jsx_runtime_1.jsx)("p", { children: "Custom data:" }, void 0), customData.map(function (item, index) {
93
149
  // eslint-disable-next-line react/no-array-index-key
94
150
  return (0, jsx_runtime_1.jsx)("p", { children: JSON.stringify(item.data) }, index);
95
151
  })] }, void 0))] }, void 0));
@@ -1 +1 @@
1
- {"version":3,"file":"Form.js","sourceRoot":"","sources":["../../src/stories/Form.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+BAAyD;AAIzD,kDAA4B;AAC5B,yCAOqB;AACrB,0CAA+D;AAC/D,wBAA0E;AAwB1E,SAAS,IAAI,CAAC,EAaD;;QAZX,MAAM,YAAA,EACN,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AAgC,EAChC,uBAAC,eAAK,IACJ,KAAK,EAAC,kEAAkE,EACxE,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,WACnC,EACD,CAAC,aAAa,IAAI,CACjB,6DACE,4FAA+C,EAC/C,uBAAC,eAAK,IACJ,KAAK,EAAC,qCAAqC,EAC3C,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,WAC9B,EACF,uBAAC,eAAK,IACJ,KAAK,EAAC,sCAAsC,EAC5C,QAAQ,EAAE,OAAO,CAAC,aAAa,CAAC,WAChC,EAEF,mFAAsC,EACtC,wCAAM,EACN,4CAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,gBAAgB,8CAEtC,EACT,4CAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,iBAAiB,gDAEvC,EACT,4CAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,iBAAiB,+CAEvC,EACT,4CAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,mBAAmB,iDAEzC,EACT,iEAAmB,EAClB,UAAU,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,KAAK;wBAC1B,oDAAoD;wBACpD,OAAO,wCAAgB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAjC,KAAK,CAAiC,CAAC;oBACxD,CAAC,CAAC,YACD,CACJ,YACI,CACR,CAAC;AACJ,CAAC;AACD,kBAAe,IAAA,YAAI,EAAC,IAAI,CAAC,CAAC"}
@@ -32,7 +32,7 @@ var variableKeys = {
32
32
  development: constants_1.FeatureVariables.MULTI_ENVIRONMENT,
33
33
  staging: constants_1.FeatureVariables.MULTI_ENVIRONMENT,
34
34
  };
35
- var withKameleoonHOCs = (0, compose_1.default)(index_1.withKameleoon, index_1.withVisitorCode, index_1.withActivateFeature, index_1.withAddData, index_1.withBrowser, index_1.withPageView, index_1.withInterest, index_1.withConversion, index_1.withTriggerExperiment, index_1.withVariationAssociatedData, (0, index_1.withFeature)({
35
+ var withKameleoonHOCs = (0, compose_1.default)(index_1.withKameleoon, index_1.withVisitorCode, index_1.withActivateFeature, index_1.withAddData, index_1.withBrowser, index_1.withPageView, index_1.withInterest, index_1.withConversion, index_1.withTriggerExperiment, index_1.withVariationAssociatedData, index_1.withRetrieveDataFromRemoteSource, (0, index_1.withFeature)({
36
36
  featureKey: constants_1.FEATURE_KEY,
37
37
  variableKeys: variableKeys,
38
38
  visitorCode: constants_1.USER_ID,
@@ -1 +1 @@
1
- {"version":3,"file":"FormHOC.js","sourceRoot":"","sources":["../../src/stories/FormHOC.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uDAAiC;AACjC,yCAAqE;AACrE,kCAYkB;AAClB,gDAA0C;AAE1C,SAAS,OAAO,CAAC,KAAiB;IAChC,OAAO,uBAAC,cAAI,eAAK,KAAK,IAAE,aAAa,EAAE,KAAK,YAAI,CAAC;AACnD,CAAC;AAED,IAAM,YAAY,GAAG;IACnB,UAAU,EAAE;QACV,4BAAgB,CAAC,MAAM;QACvB,4BAAgB,CAAC,OAAO;QACxB,4BAAgB,CAAC,MAAM;QACvB,4BAAgB,CAAC,IAAI;KACtB;IACD,WAAW,EAAE,4BAAgB,CAAC,iBAAiB;IAC/C,OAAO,EAAE,4BAAgB,CAAC,iBAAiB;CAC5C,CAAC;AAEF,IAAM,iBAAiB,GAAG,IAAA,iBAAO,EAC/B,qBAAa,EACb,uBAAe,EACf,2BAAmB,EACnB,mBAAW,EACX,mBAAW,EACX,oBAAY,EACZ,oBAAY,EACZ,sBAAc,EACd,6BAAqB,EACrB,mCAA2B,EAC3B,IAAA,mBAAW,EAAC;IACV,UAAU,EAAE,uBAAW;IACvB,YAAY,cAAA;IACZ,WAAW,EAAE,mBAAO;CACrB,CAAC,CACH,CAAC;AAEF,kBAAe,iBAAiB,CAAC,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"FormHOC.js","sourceRoot":"","sources":["../../src/stories/FormHOC.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uDAAiC;AACjC,yCAAqE;AACrE,kCAakB;AAClB,gDAA0C;AAE1C,SAAS,OAAO,CAAC,KAAiB;IAChC,OAAO,uBAAC,cAAI,eAAK,KAAK,IAAE,aAAa,EAAE,KAAK,YAAI,CAAC;AACnD,CAAC;AAED,IAAM,YAAY,GAAG;IACnB,UAAU,EAAE;QACV,4BAAgB,CAAC,MAAM;QACvB,4BAAgB,CAAC,OAAO;QACxB,4BAAgB,CAAC,MAAM;QACvB,4BAAgB,CAAC,IAAI;KACtB;IACD,WAAW,EAAE,4BAAgB,CAAC,iBAAiB;IAC/C,OAAO,EAAE,4BAAgB,CAAC,iBAAiB;CAC5C,CAAC;AAEF,IAAM,iBAAiB,GAAG,IAAA,iBAAO,EAC/B,qBAAa,EACb,uBAAe,EACf,2BAAmB,EACnB,mBAAW,EACX,mBAAW,EACX,oBAAY,EACZ,oBAAY,EACZ,sBAAc,EACd,6BAAqB,EACrB,mCAA2B,EAC3B,wCAAgC,EAChC,IAAA,mBAAW,EAAC;IACV,UAAU,EAAE,uBAAW;IACvB,YAAY,cAAA;IACZ,WAAW,EAAE,mBAAO;CACrB,CAAC,CACH,CAAC;AAEF,kBAAe,iBAAiB,CAAC,OAAO,CAAC,CAAC"}
@@ -31,6 +31,7 @@ function FormHook() {
31
31
  var trackConversion = (0, index_1.useTrackingConversion)().trackConversion;
32
32
  var getVariationId = (0, index_1.useTriggerExperiment)().getVariationId;
33
33
  var hasFeature = (0, index_1.useActivateFeature)().hasFeature;
34
+ var retrieveDataFromRemoteSource = (0, index_1.useRetrieveDataFromRemoteSource)().retrieveDataFromRemoteSource;
34
35
  var variableKeys = {
35
36
  production: [
36
37
  constants_1.FeatureVariables.STRING,
@@ -57,6 +58,7 @@ function FormHook() {
57
58
  addInterest: addInterest,
58
59
  addConversion: addConversion,
59
60
  getVariationAssociatedData: getVariationAssociatedData,
61
+ retrieveDataFromRemoteSource: retrieveDataFromRemoteSource,
60
62
  getVariationId: getVariationId,
61
63
  trackConversion: trackConversion,
62
64
  };
@@ -1 +1 @@
1
- {"version":3,"file":"FormHook.js","sourceRoot":"","sources":["../../src/stories/FormHook.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yCAAqE;AACrE,kCAakB;AAClB,gDAA0B;AAE1B,SAAgB,QAAQ;IACd,IAAA,MAAM,GAAK,IAAA,oBAAY,GAAE,OAAnB,CAAoB;IAC1B,IAAA,cAAc,GAAK,IAAA,sBAAc,GAAE,eAArB,CAAsB;IACpC,IAAA,OAAO,GAAK,IAAA,kBAAU,GAAE,QAAjB,CAAkB;IACzB,IAAA,UAAU,GAAK,IAAA,kBAAU,GAAE,WAAjB,CAAkB;IAC5B,IAAA,WAAW,GAAK,IAAA,mBAAW,GAAE,YAAlB,CAAmB;IAC9B,IAAA,WAAW,GAAK,IAAA,mBAAW,GAAE,YAAlB,CAAmB;IAC9B,IAAA,aAAa,GAAK,IAAA,qBAAa,GAAE,cAApB,CAAqB;IAClC,IAAA,0BAA0B,GAAK,IAAA,kCAA0B,GAAE,2BAAjC,CAAkC;IAC5D,IAAA,eAAe,GAAK,IAAA,6BAAqB,GAAE,gBAA5B,CAA6B;IAC5C,IAAA,cAAc,GAAK,IAAA,4BAAoB,GAAE,eAA3B,CAA4B;IAC1C,IAAA,UAAU,GAAK,IAAA,0BAAkB,GAAE,WAAzB,CAA0B;IAC5C,IAAM,YAAY,GAAG;QACnB,UAAU,EAAE;YACV,4BAAgB,CAAC,MAAM;YACvB,4BAAgB,CAAC,OAAO;YACxB,4BAAgB,CAAC,MAAM;YACvB,4BAAgB,CAAC,IAAI;SACtB;QACD,WAAW,EAAE,4BAAgB,CAAC,iBAAiB;QAC/C,OAAO,EAAE,4BAAgB,CAAC,iBAAiB;KAC5C,CAAC;IAEF,IAAM,OAAO,GAAG,IAAA,kBAAU,EAAC;QACzB,UAAU,EAAE,uBAAW;QACvB,YAAY,cAAA;QACZ,WAAW,EAAE,mBAAO;KACrB,C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C;IAE3E,IAAM,YAAY,GAAG;QACnB,UAAU,EAAE;YACV,4BAAgB,CAAC,MAAM;YACvB,4BAAgB,CAAC,OAAO;YACxB,4BAAgB,CAAC,MAAM;YACvB,4BAAgB,CAAC,IAAI;SACtB;QACD,WAAW,EAAE,4BAAgB,CAAC,iBAAiB;QAC/C,OAAO,EAAE,4BAAgB,CAAC,iBAAiB;KAC5C,CAAC;IAEF,IAAM,OAAO,GAAG,IAAA,kBAAU,EAAC;QACzB,UAAU,EAAE,uBAAW;QACvB,YAAY,cAAA;QACZ,WAAW,EAAE,mBAAO;KACrB,CAAC,CAAC;IAEH,IAAM,KAAK,GAAG;QACZ,MAAM,QAAA;QACN,OAAO,SAAA;QACP,cAAc,gBAAA;QACd,UAAU,YAAA;QACV,OAAO,SAAA;QACP,UAAU,YAAA;QACV,WAAW,aAAA;QACX,WAAW,aAAA;QACX,aAAa,eAAA;QACb,0BAA0B,4BAAA;QAC1B,4BAA4B,8BAAA;QAC5B,cAAc,gBAAA;QACd,eAAe,iBAAA;KAChB,CAAC;IAEF,OAAO,uBAAC,cAAI,eAAK,KAAK,IAAE,aAAa,EAAE,KAAK,YAAI,CAAC;AACnD,CAAC;AAhDD,4BAgDC"}
@@ -1,5 +1,6 @@
1
1
  export declare const KAMELEOON_URL = "https://app.kameleoon.com";
2
2
  export declare const KAMELEOON_SITE_CODE = "0fpmcg34lg";
3
+ export declare const KAMELEOON_VISITOR_KEY = "4rXwHd620g";
3
4
  export declare const KAMELEOON_GOAL_ID = 238446;
4
5
  export declare const FEATURE_KEY = "react_sdk_test";
5
6
  export declare const USER_ID = "98983";
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FeatureVariables = exports.GOAL_ID = exports.EXPERIMENT_ID = exports.USER_ID = exports.FEATURE_KEY = exports.KAMELEOON_GOAL_ID = exports.KAMELEOON_SITE_CODE = exports.KAMELEOON_URL = void 0;
3
+ exports.FeatureVariables = exports.GOAL_ID = exports.EXPERIMENT_ID = exports.USER_ID = exports.FEATURE_KEY = exports.KAMELEOON_GOAL_ID = exports.KAMELEOON_VISITOR_KEY = exports.KAMELEOON_SITE_CODE = exports.KAMELEOON_URL = void 0;
4
4
  exports.KAMELEOON_URL = 'https://app.kameleoon.com';
5
5
  exports.KAMELEOON_SITE_CODE = '0fpmcg34lg';
6
+ exports.KAMELEOON_VISITOR_KEY = '4rXwHd620g';
6
7
  exports.KAMELEOON_GOAL_ID = 238446;
7
8
  exports.FEATURE_KEY = 'react_sdk_test';
8
9
  exports.USER_ID = '98983';
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/stories/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,2BAA2B,CAAC;AAC5C,QAAA,mBAAmB,GAAG,YAAY,CAAC;AACnC,QAAA,iBAAiB,GAAG,MAAM,CAAC;AAC3B,QAAA,WAAW,GAAG,gBAAgB,CAAC;AAC/B,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,aAAa,GAAG,MAAM,CAAC;AACvB,QAAA,OAAO,GAAG,MAAM,CAAC;AAE9B,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,gDAA4B,CAAA;IAC5B,iDAA6B,CAAA;IAC7B,kDAA8B,CAAA;IAC9B,+CAA2B,CAAA;IAC3B,yEAAqD,CAAA;AACvD,CAAC,EANW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAM3B"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/stories/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,2BAA2B,CAAC;AAC5C,QAAA,mBAAmB,GAAG,YAAY,CAAC;AACnC,QAAA,qBAAqB,GAAG,YAAY,CAAC;AACrC,QAAA,iBAAiB,GAAG,MAAM,CAAC;AAC3B,QAAA,WAAW,GAAG,gBAAgB,CAAC;AAC/B,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,aAAa,GAAG,MAAM,CAAC;AACvB,QAAA,OAAO,GAAG,MAAM,CAAC;AAE9B,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,gDAA4B,CAAA;IAC5B,iDAA6B,CAAA;IAC7B,kDAA8B,CAAA;IAC9B,+CAA2B,CAAA;IAC3B,yEAAqD,CAAA;AACvD,CAAC,EANW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAM3B"}
package/dist/types.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { FeatureResultField } from './constants';
2
2
  export declare type AnyType = any;
3
3
  export declare type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
4
+ declare type JSONValue = string | number | boolean | {
5
+ [x: string]: JSONValue;
6
+ } | JSONValue[];
4
7
  export declare type FeatureFlagVariableType = boolean | number | string | undefined;
5
8
  export declare type FeatureVariableType = Record<string, FeatureFlagVariableType>;
6
9
  export declare type UnknownPropsType = Record<string, unknown>;
@@ -8,6 +11,7 @@ export declare type VariableKeyType = string | string[];
8
11
  export declare type VariableKeysType = {
9
12
  [environment: string]: VariableKeyType;
10
13
  };
14
+ export declare type RemoteSourceDataType = Record<string, JSONValue>;
11
15
  export interface IFeature {
12
16
  /** Feature flag status */
13
17
  [FeatureResultField.IsActive]: boolean;
@@ -22,3 +26,4 @@ export interface IFeatureParams {
22
26
  /** Unique identifier of the user */
23
27
  visitorCode?: string;
24
28
  }
29
+ export {};
@@ -0,0 +1,12 @@
1
+ import { RemoteSourceDataType } from './types';
2
+ interface RetrieveDataFromRemoteSourceHookResult {
3
+ /**
4
+ * @param key - unique key for data defined for Kameleoon Data API
5
+ */
6
+ retrieveDataFromRemoteSource: (key: string) => Promise<RemoteSourceDataType>;
7
+ }
8
+ /**
9
+ * A React Hook that returns asynchronous callback function which retrieves data from Kameleoon Data API
10
+ */
11
+ export declare function useRetrieveDataFromRemoteSource(): RetrieveDataFromRemoteSourceHookResult;
12
+ export {};
@@ -0,0 +1,76 @@
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
+ /**
44
+ * A React Hook that returns asynchronous callback function which retrieves data from Kameleoon Data API
45
+ */
46
+ function useRetrieveDataFromRemoteSource() {
47
+ var _this = this;
48
+ var client = (0, useKameleoon_1.useKameleoon)().client;
49
+ var isObjectEmpty = (0, react_1.useCallback)(function (object) {
50
+ return (object &&
51
+ Object.keys(object).length === 0 &&
52
+ Object.getPrototypeOf(object) === Object.prototype);
53
+ }, []);
54
+ var retrieveDataFromRemoteSource = (0, react_1.useCallback)(function (key) { return __awaiter(_this, void 0, void 0, function () {
55
+ var data;
56
+ return __generator(this, function (_a) {
57
+ switch (_a.label) {
58
+ case 0: return [4 /*yield*/, client.retrieveDataFromRemoteSource(key)];
59
+ case 1:
60
+ data = (_a.sent());
61
+ if (isObjectEmpty(data)) {
62
+ throw new Error('No data was retrieved from remote source or the data is empty');
63
+ }
64
+ return [2 /*return*/, data];
65
+ }
66
+ });
67
+ }); }, [client, isObjectEmpty]);
68
+ if (!client) {
69
+ throw new ProviderError_1.ProviderError('useKameleoon');
70
+ }
71
+ return {
72
+ retrieveDataFromRemoteSource: retrieveDataFromRemoteSource,
73
+ };
74
+ }
75
+ exports.useRetrieveDataFromRemoteSource = useRetrieveDataFromRemoteSource;
76
+ //# 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;AAUhD;;GAEG;AACH,SAAgB,+BAA+B;IAA/C,iBAmCC;IAlCS,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;;;;wBACF,qBAAM,MAAM,CAAC,4BAA4B,CACrD,GAAG,CACJ,EAAA;;oBAFK,IAAI,GAAG,CAAC,SAEb,CAAyB;oBAE1B,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;wBACvB,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;qBACH;oBAED,sBAAO,IAAI,EAAC;;;SACb,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;AAnCD,0EAmCC"}
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { UnknownPropsType, Without, RemoteSourceDataType } from './types';
3
+ interface IWithRetrieveDataFromRemoteSource {
4
+ /**
5
+ * @param key - unique key for data defined for Kameleoon Data API
6
+ */
7
+ retrieveDataFromRemoteSource: (key: string) => Promise<RemoteSourceDataType>;
8
+ }
9
+ /**
10
+ * A React HOC that gives a wrapped component access to callback function
11
+ * which retrieves data from Kameleoon Data API
12
+ */
13
+ export declare function withRetrieveDataFromRemoteSource<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithRetrieveDataFromRemoteSource>>;
14
+ 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.withRetrieveDataFromRemoteSource = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var useRetrieveDataFromRemoteSource_1 = require("./useRetrieveDataFromRemoteSource");
17
+ /**
18
+ * A React HOC that gives a wrapped component access to callback function
19
+ * which retrieves data from Kameleoon Data API
20
+ */
21
+ function withRetrieveDataFromRemoteSource(Component) {
22
+ return function WrappedComponent(props) {
23
+ var retrieveDataFromRemoteSource = (0, useRetrieveDataFromRemoteSource_1.useRetrieveDataFromRemoteSource)().retrieveDataFromRemoteSource;
24
+ return ((0, jsx_runtime_1.jsx)(Component, __assign({ retrieveDataFromRemoteSource: retrieveDataFromRemoteSource }, props), void 0));
25
+ };
26
+ }
27
+ exports.withRetrieveDataFromRemoteSource = withRetrieveDataFromRemoteSource;
28
+ //# sourceMappingURL=withRetrieveDataFromRemoteSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withRetrieveDataFromRemoteSource.js","sourceRoot":"","sources":["../src/withRetrieveDataFromRemoteSource.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,qFAAoF;AASpF;;;GAGG;AACH,SAAgB,gCAAgC,CAG9C,SAAqC;IAIrC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACnC,IAAA,4BAA4B,GAAK,IAAA,iEAA+B,GAAE,6BAAtC,CAAuC;QAE3E,OAAO,CACL,uBAAC,SAAS,aACR,4BAA4B,EAAE,4BAA4B,IACrD,KAAe,UACpB,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAjBD,4EAiBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/react-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.1.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.6",
38
+ "kameleoon-client-javascript": "^1.0.7",
38
39
  "validator": "^13.6.0"
39
40
  },
40
41
  "devDependencies": {