@kameleoon/react-sdk 7.5.4 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +3 -7
  2. package/dist/KameleoonContext.js +1 -1
  3. package/dist/KameleoonContext.js.map +1 -1
  4. package/dist/KameleoonProvider.js +1 -3
  5. package/dist/KameleoonProvider.js.map +1 -1
  6. package/dist/eventSource/browserEventSource.js +1 -6
  7. package/dist/eventSource/browserEventSource.js.map +1 -1
  8. package/dist/eventSource/nativeEventSource.js +1 -1
  9. package/dist/eventSource/nativeEventSource.js.map +1 -1
  10. package/dist/index.d.ts +4 -6
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/kameleoonClient.d.ts +3 -2
  14. package/dist/kameleoonClient.js +1 -5
  15. package/dist/kameleoonClient.js.map +1 -1
  16. package/dist/kameleoonUtils/browserUtils.js +1 -14
  17. package/dist/kameleoonUtils/browserUtils.js.map +1 -1
  18. package/dist/kameleoonUtils/nativeUtils.js +1 -12
  19. package/dist/kameleoonUtils/nativeUtils.js.map +1 -1
  20. package/dist/requester.js +1 -1
  21. package/dist/requester.js.map +1 -1
  22. package/dist/storage/localStorage.js +1 -1
  23. package/dist/storage/localStorage.js.map +1 -1
  24. package/dist/storage/nativeStorage.js +1 -1
  25. package/dist/storage/nativeStorage.js.map +1 -1
  26. package/dist/types.d.ts +9 -0
  27. package/dist/types.js +2 -0
  28. package/dist/types.js.map +1 -0
  29. package/dist/useAddData.d.ts +1 -1
  30. package/dist/useAddData.js +1 -5
  31. package/dist/useAddData.js.map +1 -1
  32. package/dist/useBrowserVisitorCode.js +1 -5
  33. package/dist/useBrowserVisitorCode.js.map +1 -1
  34. package/dist/useConfigurationUpdate.d.ts +1 -1
  35. package/dist/useConfigurationUpdate.js +1 -5
  36. package/dist/useConfigurationUpdate.js.map +1 -1
  37. package/dist/useEngineTrackingCode.js.map +1 -1
  38. package/dist/useFeatureFlagActive.d.ts +2 -2
  39. package/dist/useFeatureFlagActive.js +1 -5
  40. package/dist/useFeatureFlagActive.js.map +1 -1
  41. package/dist/useFeatureFlagVariationKey.d.ts +2 -2
  42. package/dist/useFeatureFlagVariationKey.js +1 -5
  43. package/dist/useFeatureFlagVariationKey.js.map +1 -1
  44. package/dist/useFeatureFlags.d.ts +1 -1
  45. package/dist/useFeatureFlags.js +1 -5
  46. package/dist/useFeatureFlags.js.map +1 -1
  47. package/dist/useFeatureVariable.d.ts +4 -4
  48. package/dist/useFeatureVariable.js +1 -5
  49. package/dist/useFeatureVariable.js.map +1 -1
  50. package/dist/useFeatureVariables.d.ts +25 -0
  51. package/dist/useFeatureVariables.js +2 -0
  52. package/dist/useFeatureVariables.js.map +1 -0
  53. package/dist/useFlush.d.ts +1 -1
  54. package/dist/useFlush.js +1 -5
  55. package/dist/useFlush.js.map +1 -1
  56. package/dist/useInitialize.js +1 -5
  57. package/dist/useInitialize.js.map +1 -1
  58. package/dist/useKameleoon.js +1 -6
  59. package/dist/useKameleoon.js.map +1 -1
  60. package/dist/useNativeVisitorCode.js +1 -5
  61. package/dist/useNativeVisitorCode.js.map +1 -1
  62. package/dist/useRemoteData.js +1 -5
  63. package/dist/useRemoteData.js.map +1 -1
  64. package/dist/useRemoteVisitorData.d.ts +5 -5
  65. package/dist/useRemoteVisitorData.js +1 -5
  66. package/dist/useRemoteVisitorData.js.map +1 -1
  67. package/dist/useTrackConversion.js +1 -5
  68. package/dist/useTrackConversion.js.map +1 -1
  69. package/dist/useVisitorFeatureFlags.d.ts +1 -1
  70. package/dist/useVisitorFeatureFlags.js +1 -5
  71. package/dist/useVisitorFeatureFlags.js.map +1 -1
  72. package/dist/useVisitorWarehouseAudience.d.ts +24 -0
  73. package/dist/useVisitorWarehouseAudience.js +2 -0
  74. package/dist/useVisitorWarehouseAudience.js.map +1 -0
  75. package/package.json +2 -2
  76. package/dist/useExperimentVariationData.d.ts +0 -21
  77. package/dist/useExperimentVariationData.js +0 -6
  78. package/dist/useExperimentVariationData.js.map +0 -1
  79. package/dist/useExperiments.d.ts +0 -18
  80. package/dist/useExperiments.js +0 -6
  81. package/dist/useExperiments.js.map +0 -1
  82. package/dist/useFlushData.d.ts +0 -19
  83. package/dist/useFlushData.js +0 -4
  84. package/dist/useFlushData.js.map +0 -1
  85. package/dist/useTriggerExperiment.d.ts +0 -24
  86. package/dist/useTriggerExperiment.js +0 -6
  87. package/dist/useTriggerExperiment.js.map +0 -1
  88. package/dist/useVisitorExperiments.d.ts +0 -22
  89. package/dist/useVisitorExperiments.js +0 -6
  90. package/dist/useVisitorExperiments.js.map +0 -1
@@ -1,6 +1,2 @@
1
- "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRemoteData=useRemoteData;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}/**
2
- * A React Hook that returns asynchronous getRemoteData function which retrieves data from Kameleoon server.
3
- *
4
- * @returns {IRemoteDataHookResult} an object containing the `getRemoteData` function.
5
- */function useRemoteData(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a){return _regeneratorRuntime().wrap(function d(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,b.getRemoteData(a);case 2:return c.abrupt("return",c.sent);case 3:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}(),[b]);return{getRemoteData:c}}
1
+ "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRemoteData=useRemoteData;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function useRemoteData(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(){var a=_asyncToGenerator(_regeneratorRuntime().mark(function c(a){return _regeneratorRuntime().wrap(function d(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,b.getRemoteData(a);case 2:return c.abrupt("return",c.sent);case 3:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}(),[b]);return{getRemoteData:c}}
6
2
  //# sourceMappingURL=useRemoteData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRemoteData.js","names":["a","b","c","Object","defineProperty","value","enumerable","configurable","writable","e","f","prototype","d","g","create","h","m","s","i","type","arg","call","forEach","_invoke","j","k","_typeof","r","resolve","__await","then","Error","o","method","delegate","x","sent","_sent","dispatchException","abrupt","done","iterator","return","TypeError","resultName","next","nextLoc","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","l","completion","reset","n","u","isNaN","length","_regeneratorRuntime","p","q","hasOwnProperty","t","Symbol","v","asyncIterator","w","toStringTag","wrap","y","z","getPrototypeOf","A","B","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","AsyncIterator","async","Promise","keys","reverse","pop","values","prev","charAt","slice","stop","rval","complete","finish","catch","_catch","delegateYield","asyncGeneratorStep","_asyncToGenerator","arguments","apply","useRemoteData","useKameleoon","client","getRemoteData","useCallback","key"],"sources":["../src/useRemoteData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { JSONType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IRemoteDataHookResult {\n /**\n * Returns a data which is stored for specified siteCode on a remote Kameleoon server.\n *\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {Promise<JSONType>} promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server.\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n}\n\n/**\n * A React Hook that returns asynchronous getRemoteData function which retrieves data from Kameleoon server.\n *\n * @returns {IRemoteDataHookResult} an object containing the `getRemoteData` function.\n */\nexport function useRemoteData(): IRemoteDataHookResult {\n const { client } = useKameleoon();\n\n const getRemoteData = useCallback(\n async (key: string): Promise<JSONType> => {\n return await client.getRemoteData(key);\n },\n [client],\n );\n\n return {\n getRemoteData,\n };\n}\n"],"mappings":"2eACA,6JAAAA,GAAA,CAAAC,CAAA,CAAAC,CAAA,SAAAC,MAAA,CAAAC,cAAA,CAAAJ,CAAA,CAAAC,CAAA,EAAAI,KAAA,CAAAH,CAAA,CAAAI,UAAA,IAAAC,YAAA,IAAAC,QAAA,MAAAR,CAAA,CAAAC,CAAA,WAAAA,EAAAD,CAAA,CAAAC,CAAA,CAAAC,CAAA,CAAAO,CAAA,MAAAC,CAAA,CAAAT,CAAA,EAAAA,CAAA,CAAAU,SAAA,YAAAC,CAAA,CAAAX,CAAA,CAAAW,CAAA,CAAAC,CAAA,CAAAV,MAAA,CAAAW,MAAA,CAAAJ,CAAA,CAAAC,SAAA,EAAAI,CAAA,KAAAC,CAAA,CAAAP,CAAA,aAAAQ,CAAA,CAAAJ,CAAA,YAAAR,KAAA,CAAAa,CAAA,CAAAlB,CAAA,CAAAE,CAAA,CAAAa,CAAA,IAAAF,CAAA,UAAAX,EAAAF,CAAA,CAAAC,CAAA,CAAAC,CAAA,aAAAiB,IAAA,UAAAC,GAAA,CAAApB,CAAA,CAAAqB,IAAA,CAAApB,C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AvG,CAAA,CAAAC,CAAA,EAAAQ,CAAA,YAgBA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAA+F,aAAaA,CAAA,CAA0B,KAAAzG,CAAA,CAClC,GAAA0G,2BAAY,GAAE,CAAzBC,CAAM,CAAA3G,CAAA,CAAN2G,MAAM,CAERC,CAAa,CAAG,GAAAC,kBAAW,8BAAA7G,CAAA,CAAAsG,iBAAA,cAAA1C,mBAAA,GAAAoB,IAAA,CAC/B,SAAA9E,EAAO4G,CAAW,SAAAlD,mBAAA,GAAAU,IAAA,UAAA1D,EAAAV,CAAA,iBAAAA,CAAA,CAAAyF,IAAA,CAAAzF,CAAA,CAAA2C,IAAA,gBAAA3C,CAAA,CAAA2C,IAAA,GACH8D,CAAM,CAACC,aAAa,CAACE,CAAG,CAAC,eAAA5G,CAAA,CAAAqC,MAAA,UAAArC,CAAA,CAAAkC,IAAA,0BAAAlC,CAAA,CAAA4F,IAAA,MAAA5F,CAAA,EACvC,mBAAAD,CAAA,SAAAD,CAAA,CAAAwG,KAAA,MAAAD,SAAA,MACD,CAACI,CAAM,CAAC,CACT,CAED,MAAO,CACLC,aAAa,CAAbA,CACF,CACF"}
1
+ {"version":3,"file":"useRemoteData.js","names":["useRemoteData","a","useKameleoon","client","getRemoteData","useCallback","_asyncToGenerator","_regeneratorRuntime","mark","c","key","wrap","d","prev","next","abrupt","sent","stop","b","apply","arguments"],"sources":["../src/useRemoteData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { JSONType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IRemoteDataHookResult {\n /**\n * Returns a data which is stored for specified siteCode on a remote Kameleoon server.\n *\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {Promise<JSONType>} promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server.\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n}\n\n/**\n * A React Hook that returns asynchronous getRemoteData function which retrieves data from Kameleoon server.\n *\n * @returns {IRemoteDataHookResult} an object containing the `getRemoteData` function.\n */\nexport function useRemoteData(): IRemoteDataHookResult {\n const { client } = useKameleoon();\n\n const getRemoteData = useCallback(\n async (key: string): Promise<JSONType> => {\n return await client.getRemoteData(key);\n },\n [client],\n );\n\n return {\n getRemoteData,\n };\n}\n"],"mappings":"s0OAsBO,QAAS,CAAAA,aAAaA,CAAA,CAA0B,KAAAC,CAAA,CAClC,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAa,CAAG,GAAAC,kBAAW,iBAAAJ,CAAA,CAAAK,iBAAA,CAAAC,mBAAA,GAAAC,IAAA,CAC/B,SAAAC,EAAOC,CAAW,SAAAH,mBAAA,GAAAI,IAAA,UAAAC,EAAAH,CAAA,iBAAAA,CAAA,CAAAI,IAAA,CAAAJ,CAAA,CAAAK,IAAA,gBAAAL,CAAA,CAAAK,IAAA,GACHX,CAAM,CAACC,aAAa,CAACM,CAAG,CAAC,eAAAD,CAAA,CAAAM,MAAA,UAAAN,CAAA,CAAAO,IAAA,0BAAAP,CAAA,CAAAQ,IAAA,MAAAR,CAAA,EACvC,mBAAAS,CAAA,SAAAjB,CAAA,CAAAkB,KAAA,MAAAC,SAAA,MACD,CAACjB,CAAM,CAAC,CACT,CAED,MAAO,CACLC,aAAa,CAAbA,CACF,CACF"}
@@ -1,19 +1,19 @@
1
- import { KameleoonDataType } from '@kameleoon/javascript-sdk-core';
1
+ import { KameleoonDataType, RemoteVisitorDataParamsType } from '@kameleoon/javascript-sdk-core';
2
2
  export interface IRemoteVisitorDataHookResult {
3
3
  /**
4
4
  * An asynchronous method for retrieving custom data for the latest visit of `visitorCode` from Kameleoon Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.
5
5
  *
6
- * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
7
- * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`
8
- *
6
+ * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters
9
7
  * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data
10
8
  * @throws `KameleoonError` with one of the following `type` s:
11
9
  *
12
10
  * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
13
11
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
14
12
  * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server
13
+ * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25
14
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
15
15
  */
16
- getRemoteVisitorData: (visitorCode: string, shouldAddData?: boolean) => Promise<KameleoonDataType[]>;
16
+ getRemoteVisitorData: ({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;
17
17
  }
18
18
  /**
19
19
  * A React Hook that returns asynchronous getRemoteVisitorData function which retrieves custom data from Kameleoon server and optionally adds it to storage.
@@ -1,6 +1,2 @@
1
- "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRemoteVisitorData=useRemoteVisitorData;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}/**
2
- * A React Hook that returns asynchronous getRemoteVisitorData function which retrieves custom data from Kameleoon server and optionally adds it to storage.
3
- *
4
- * @returns {IRemoteVisitorDataHookResult} an object containing the `getRemoteVisitorData` function.
5
- */function useRemoteVisitorData(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,c){return _regeneratorRuntime().wrap(function e(d){for(;1;)switch(d.prev=d.next){case 0:return d.next=2,b.getRemoteVisitorData(a,c);case 2:return d.abrupt("return",d.sent);case 3:case"end":return d.stop();}},d)}));return function(b,c){return a.apply(this,arguments)}}(),[b]);return{getRemoteVisitorData:c}}
1
+ "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRemoteVisitorData=useRemoteVisitorData;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function useRemoteVisitorData(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(){var a=_asyncToGenerator(_regeneratorRuntime().mark(function c(a){return _regeneratorRuntime().wrap(function d(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,b.getRemoteVisitorData(a);case 2:return c.abrupt("return",c.sent);case 3:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}(),[b]);return{getRemoteVisitorData:c}}
6
2
  //# sourceMappingURL=useRemoteVisitorData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRemoteVisitorData.js","names":["a","b","c","Object","defineProperty","value","enumerable","configurable","writable","e","f","prototype","d","g","create","h","m","s","i","type","arg","call","forEach","_invoke","j","k","_typeof","r","resolve","__await","then","Error","o","method","delegate","x","sent","_sent","dispatchException","abrupt","done","iterator","return","TypeError","resultName","next","nextLoc","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","l","completion","reset","n","u","isNaN","length","_regeneratorRuntime","p","q","hasOwnProperty","t","Symbol","v","asyncIterator","w","toStringTag","wrap","y","z","getPrototypeOf","A","B","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","AsyncIterator","async","Promise","keys","reverse","pop","values","prev","charAt","slice","stop","rval","complete","finish","catch","_catch","delegateYield","asyncGeneratorStep","_asyncToGenerator","arguments","apply","useRemoteVisitorData","useKameleoon","client","getRemoteVisitorData","useCallback","visitorCode","shouldAddData"],"sources":["../src/useRemoteVisitorData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\nimport { KameleoonDataType } from '@kameleoon/javascript-sdk-core';\n\nexport interface IRemoteVisitorDataHookResult {\n /**\n * An asynchronous method for retrieving custom data for the latest visit of `visitorCode` from Kameleoon Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n *\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getRemoteVisitorData: (\n visitorCode: string,\n shouldAddData?: boolean,\n ) => Promise<KameleoonDataType[]>;\n}\n\n/**\n * A React Hook that returns asynchronous getRemoteVisitorData function which retrieves custom data from Kameleoon server and optionally adds it to storage.\n *\n * @returns {IRemoteVisitorDataHookResult} an object containing the `getRemoteVisitorData` function.\n */\nexport function useRemoteVisitorData(): IRemoteVisitorDataHookResult {\n const { client } = useKameleoon();\n\n const getRemoteVisitorData = useCallback(\n async (\n visitorCode: string,\n shouldAddData?: boolean,\n ): Promise<KameleoonDataType[]> => {\n return await client.getRemoteVisitorData(visitorCode, shouldAddData);\n },\n [client],\n );\n\n return {\n getRemoteVisitorData,\n };\n}\n"],"mappings":"yfACA,6JAAAA,GAAA,CAAAC,CAAA,CAAAC,CAAA,SAAAC,MAAA,CAAAC,cAAA,CAAAJ,CAAA,CAAAC,CAAA,EAAAI,KAAA,CAAAH,CAAA,CAAAI,UAAA,IAAAC,YAAA,IAAAC,QAAA,MAAAR,CAAA,CAAAC,CAAA,WAAAA,EAAAD,CAAA,CAAAC,CAAA,CAAAC,CAAA,CAAAO,CAAA,MAAAC,CAAA,CAAAT,CAAA,EAAAA,CAAA,CAAAU,SAAA,YAAAC,CAAA,CAAAX,CAAA,CAAAW,CAAA,CAAAC,CAAA,CAAAV,MAAA,CAAAW,MAAA,CAAAJ,CAAA,CAAAC,SAAA,EAAAI,CAAA,KAAAC,CAAA,CAAAP,CAAA,aAAAQ,CAAA,CAAAJ,CAAA,YAAAR,KAAA,CAAAa,CAAA,CAAAlB,CAAA,CAAAE,CAAA,CAAAa,CAAA,IAAAF,CAAA,UAAAX,EAAAF,CAAA,CAAAC,CAAA,CAAAC,CAAA,aAAAiB,IAAA,UAAAC,GAAA,CAAApB,CAAA,CAAAqB,IAAA,CAAApB,CAAA,CAAAC,CAAA,SAAAF,CAAA,SAAAmB,IAAA,SAAAC,GAAA,CAAApB,CAAA,YAAAY,EAAA,YAAAH,EAAA,YAAAC,EAAA,YAAAG,EAAAZ,CAAA,4BAAAqB,OAAA,UAAApB,CAAA,EAAAF,CAAA,CAAAC,CAAA,CAAAC,CAAA,UAAAF,CAAA,cAAAuB,OAAA,CAAArB,CAAA,CAAAF,CAAA,eAAAe,EAAAf,CAAA,CAAAC,CAAA,WAAAW,EAAAH,CAAA,CAAAC,CAAA,CAAAG,CAAA,CAAAE,CAAA,MAAAG,CAAA,CAAAhB,CAAA,CAAAF,CAAA,CAAAS,CAAA,EAAAT,CAAA,CAA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A,CAAAiC,IAAA,gBAAAjC,CAAA,CAAAiC,IAAA,GAEV8D,CAAM,CAACC,oBAAoB,CAACE,CAAW,CAAEC,CAAa,CAAC,eAAAnG,CAAA,CAAA2B,MAAA,UAAA3B,CAAA,CAAAwB,IAAA,0BAAAxB,CAAA,CAAAkF,IAAA,MAAAlF,CAAA,EACrE,mBAAAX,CAAA,CAAAC,CAAA,SAAAF,CAAA,CAAAwG,KAAA,MAAAD,SAAA,MACD,CAACI,CAAM,CAAC,CACT,CAED,MAAO,CACLC,oBAAoB,CAApBA,CACF,CACF"}
1
+ {"version":3,"file":"useRemoteVisitorData.js","names":["useRemoteVisitorData","a","useKameleoon","client","getRemoteVisitorData","useCallback","_asyncToGenerator","_regeneratorRuntime","mark","c","params","wrap","d","prev","next","abrupt","sent","stop","b","apply","arguments"],"sources":["../src/useRemoteVisitorData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\nimport {\n KameleoonDataType,\n RemoteVisitorDataParamsType,\n} from '@kameleoon/javascript-sdk-core';\n\nexport interface IRemoteVisitorDataHookResult {\n /**\n * An asynchronous method for retrieving custom data for the latest visit of `visitorCode` from Kameleoon Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n *\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n}\n\n/**\n * A React Hook that returns asynchronous getRemoteVisitorData function which retrieves custom data from Kameleoon server and optionally adds it to storage.\n *\n * @returns {IRemoteVisitorDataHookResult} an object containing the `getRemoteVisitorData` function.\n */\nexport function useRemoteVisitorData(): IRemoteVisitorDataHookResult {\n const { client } = useKameleoon();\n\n const getRemoteVisitorData = useCallback(\n async (\n params: RemoteVisitorDataParamsType,\n ): Promise<KameleoonDataType[]> => {\n return await client.getRemoteVisitorData(params);\n },\n [client],\n );\n\n return {\n getRemoteVisitorData,\n };\n}\n"],"mappings":"o1OAiCO,QAAS,CAAAA,oBAAoBA,CAAA,CAAiC,KAAAC,CAAA,CAChD,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAoB,CAAG,GAAAC,kBAAW,iBAAAJ,CAAA,CAAAK,iBAAA,CAAAC,mBAAA,GAAAC,IAAA,CACtC,SAAAC,EACEC,CAAmC,SAAAH,mBAAA,GAAAI,IAAA,UAAAC,EAAAH,CAAA,iBAAAA,CAAA,CAAAI,IAAA,CAAAJ,CAAA,CAAAK,IAAA,gBAAAL,CAAA,CAAAK,IAAA,GAEtBX,CAAM,CAACC,oBAAoB,CAACM,CAAM,CAAC,eAAAD,CAAA,CAAAM,MAAA,UAAAN,CAAA,CAAAO,IAAA,0BAAAP,CAAA,CAAAQ,IAAA,MAAAR,CAAA,EACjD,mBAAAS,CAAA,SAAAjB,CAAA,CAAAkB,KAAA,MAAAC,SAAA,MACD,CAACjB,CAAM,CAAC,CACT,CAED,MAAO,CACLC,oBAAoB,CAApBA,CACF,CACF"}
@@ -1,6 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useTrackConversion=useTrackConversion;var _react=require("react"),_useKameleoon2=require("./useKameleoon");/**
2
- * A React Hook that returns trackConversion function which tracks conversion.
3
- *
4
- * @returns {ITrackConversionHookResult} an object containing the `trackConversion` function.
5
- */function useTrackConversion(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){var c=a.visitorCode,d=a.goalId,e=a.revenue;b.trackConversion({visitorCode:c,goalId:d,revenue:e})},[b]);return{trackConversion:c}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useTrackConversion=useTrackConversion;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function useTrackConversion(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){var c=a.visitorCode,d=a.goalId,e=a.revenue;b.trackConversion({visitorCode:c,goalId:d,revenue:e})},[b]);return{trackConversion:c}}
6
2
  //# sourceMappingURL=useTrackConversion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTrackConversion.js","names":["useTrackConversion","a","useKameleoon","client","trackConversion","useCallback","visitorCode","goalId","revenue"],"sources":["../src/useTrackConversion.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { TrackConversionParamsType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface ITrackConversionHookResult {\n /**\n * Creates and adds `Conversion` data to the visitor with specified parameters and executes `flushData`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter.\n *\n * @param {TrackConversionParamsType} params - `visitorCode`, `goalId` and `revenue` parameters for data tracking.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data.\n */\n trackConversion: (params: TrackConversionParamsType) => void;\n}\n\n/**\n * A React Hook that returns trackConversion function which tracks conversion.\n *\n * @returns {ITrackConversionHookResult} an object containing the `trackConversion` function.\n */\nexport function useTrackConversion(): ITrackConversionHookResult {\n const { client } = useKameleoon();\n\n const trackConversion = useCallback(\n ({ visitorCode, goalId, revenue }: TrackConversionParamsType): void => {\n client.trackConversion({ visitorCode, goalId, revenue });\n },\n [client],\n );\n\n return {\n trackConversion,\n };\n}\n"],"mappings":"uLAkBA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,kBAAkBA,CAAA,CAA+B,KAAAC,CAAA,CAC5C,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAe,CAAG,GAAAC,kBAAW,EACjC,SAAAJ,CAAA,CAAuE,IAApE,CAAAK,CAAW,CAAAL,CAAA,CAAXK,WAAW,CAAEC,CAAM,CAAAN,CAAA,CAANM,MAAM,CAAEC,CAAO,CAAAP,CAAA,CAAPO,OAAO,CAC7BL,CAAM,CAACC,eAAe,CAAC,CAAEE,WAAW,CAAXA,CAAW,CAAEC,MAAM,CAANA,CAAM,CAAEC,OAAO,CAAPA,CAAQ,CAAC,CACzD,CAAC,CACD,CAACL,CAAM,CAAC,CACT,CAED,MAAO,CACLC,eAAe,CAAfA,CACF,CACF"}
1
+ {"version":3,"file":"useTrackConversion.js","names":["useTrackConversion","a","useKameleoon","client","trackConversion","useCallback","visitorCode","goalId","revenue"],"sources":["../src/useTrackConversion.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { TrackConversionParamsType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface ITrackConversionHookResult {\n /**\n * Creates and adds `Conversion` data to the visitor with specified parameters and executes `flushData`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter.\n *\n * @param {TrackConversionParamsType} params - `visitorCode`, `goalId` and `revenue` parameters for data tracking.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data.\n */\n trackConversion: (params: TrackConversionParamsType) => void;\n}\n\n/**\n * A React Hook that returns trackConversion function which tracks conversion.\n *\n * @returns {ITrackConversionHookResult} an object containing the `trackConversion` function.\n */\nexport function useTrackConversion(): ITrackConversionHookResult {\n const { client } = useKameleoon();\n\n const trackConversion = useCallback(\n ({ visitorCode, goalId, revenue }: TrackConversionParamsType): void => {\n client.trackConversion({ visitorCode, goalId, revenue });\n },\n [client],\n );\n\n return {\n trackConversion,\n };\n}\n"],"mappings":"uLAuBO,QAAS,CAAAA,kBAAkBA,CAAA,CAA+B,KAAAC,CAAA,CAC5C,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAe,CAAG,GAAAC,kBAAW,EACjC,SAAAJ,CAAA,CAAuE,IAApE,CAAAK,CAAW,CAAAL,CAAA,CAAXK,WAAW,CAAEC,CAAM,CAAAN,CAAA,CAANM,MAAM,CAAEC,CAAO,CAAAP,CAAA,CAAPO,OAAO,CAC7BL,CAAM,CAACC,eAAe,CAAC,CAAEE,WAAW,CAAXA,CAAW,CAAEC,MAAM,CAANA,CAAM,CAAEC,OAAO,CAAPA,CAAQ,CAAC,CACzD,CAAC,CACD,CAACL,CAAM,CAAC,CACT,CAED,MAAO,CACLC,eAAe,CAAfA,CACF,CACF"}
@@ -9,7 +9,7 @@ export interface IVisitorFeatureFlagsHookResult {
9
9
  *
10
10
  * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.
11
11
  * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
12
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
12
+ * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.
13
13
  * - `KameleoonException.NotTargeted` - Current visitor is not targeted.
14
14
  */
15
15
  getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];
@@ -1,6 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useVisitorFeatureFlags=useVisitorFeatureFlags;var _react=require("react"),_useKameleoon2=require("./useKameleoon");/**
2
- * A React Hook that returns `getVisitorFeatureFlags` function which returns a list of feature flags that the visitor with `visitorCode` that is targeted by.
3
- *
4
- * @returns {IVisitorFeatureFlagsHookResult} an object containing the `getVisitorFeatureFlags` function.
5
- */function useVisitorFeatureFlags(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){return b.getVisitorFeatureFlags(a)},[b]);return{getVisitorFeatureFlags:c}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useVisitorFeatureFlags=useVisitorFeatureFlags;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function useVisitorFeatureFlags(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){return b.getVisitorFeatureFlags(a)},[b]);return{getVisitorFeatureFlags:c}}
6
2
  //# sourceMappingURL=useVisitorFeatureFlags.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useVisitorFeatureFlags.js","names":["useVisitorFeatureFlags","a","useKameleoon","client","getVisitorFeatureFlags","useCallback","visitorCode"],"sources":["../src/useVisitorFeatureFlags.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { FeatureFlagType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IVisitorFeatureFlagsHookResult {\n /**\n * Returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n}\n\n/**\n * A React Hook that returns `getVisitorFeatureFlags` function which returns a list of feature flags that the visitor with `visitorCode` that is targeted by.\n *\n * @returns {IVisitorFeatureFlagsHookResult} an object containing the `getVisitorFeatureFlags` function.\n */\nexport function useVisitorFeatureFlags(): IVisitorFeatureFlagsHookResult {\n const { client } = useKameleoon();\n\n const getVisitorFeatureFlags = useCallback(\n (visitorCode: string): FeatureFlagType[] => {\n return client.getVisitorFeatureFlags(visitorCode);\n },\n [client],\n );\n\n return {\n getVisitorFeatureFlags,\n };\n}\n"],"mappings":"+LAoBA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,sBAAsBA,CAAA,CAAmC,KAAAC,CAAA,CACpD,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAsB,CAAG,GAAAC,kBAAW,EACxC,SAACC,CAAmB,CAAwB,CAC1C,MAAO,CAAAH,CAAM,CAACC,sBAAsB,CAACE,CAAW,CAClD,CAAC,CACD,CAACH,CAAM,CAAC,CACT,CAED,MAAO,CACLC,sBAAsB,CAAtBA,CACF,CACF"}
1
+ {"version":3,"file":"useVisitorFeatureFlags.js","names":["useVisitorFeatureFlags","a","useKameleoon","client","getVisitorFeatureFlags","useCallback","visitorCode"],"sources":["../src/useVisitorFeatureFlags.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { FeatureFlagType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IVisitorFeatureFlagsHookResult {\n /**\n * Returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted.\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n}\n\n/**\n * A React Hook that returns `getVisitorFeatureFlags` function which returns a list of feature flags that the visitor with `visitorCode` that is targeted by.\n *\n * @returns {IVisitorFeatureFlagsHookResult} an object containing the `getVisitorFeatureFlags` function.\n */\nexport function useVisitorFeatureFlags(): IVisitorFeatureFlagsHookResult {\n const { client } = useKameleoon();\n\n const getVisitorFeatureFlags = useCallback(\n (visitorCode: string): FeatureFlagType[] => {\n return client.getVisitorFeatureFlags(visitorCode);\n },\n [client],\n );\n\n return {\n getVisitorFeatureFlags,\n };\n}\n"],"mappings":"+LAyBO,QAAS,CAAAA,sBAAsBA,CAAA,CAAmC,KAAAC,CAAA,CACpD,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAsB,CAAG,GAAAC,kBAAW,EACxC,SAACC,CAAmB,CAAwB,CAC1C,MAAO,CAAAH,CAAM,CAACC,sBAAsB,CAACE,CAAW,CAClD,CAAC,CACD,CAACH,CAAM,CAAC,CACT,CAED,MAAO,CACLC,sBAAsB,CAAtBA,CACF,CACF"}
@@ -0,0 +1,24 @@
1
+ import { GetVisitorWarehouseAudienceParamsType, CustomData } from '@kameleoon/javascript-sdk-core';
2
+ export interface IVisitorWarehouseAudienceHookResult {
3
+ /**
4
+ * An asynchronous method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences
5
+ * which is stored for specified visitorCode on a remote Kameleoon server
6
+ * Retrieved data will be added to storage under the specified `customDataIndex`
7
+ *
8
+ * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details
9
+ *
10
+ * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`
11
+ * @throws `KameleoonError` with one of the following `type` s:
12
+ *
13
+ * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
14
+ * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty
15
+ * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server
16
+ */
17
+ getVisitorWarehouseAudience: ({ visitorCode, customDataIndex, warehouseKey, }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;
18
+ }
19
+ /**
20
+ * A React Hook that returns asynchronous `getVisitorWarehouseAudience` function which retrieves warehouse audiences data
21
+ *
22
+ * @returns {IVisitorWarehouseAudienceHookResult} an object containing the `getVisitorWarehouseAudience` function.
23
+ */
24
+ export declare function useVisitorWarehouseAudience(): IVisitorWarehouseAudienceHookResult;
@@ -0,0 +1,2 @@
1
+ "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.useVisitorWarehouseAudience=useVisitorWarehouseAudience;var _react=require("react"),_useKameleoon2=require("./useKameleoon");function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function useVisitorWarehouseAudience(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(){var a=_asyncToGenerator(_regeneratorRuntime().mark(function c(a){return _regeneratorRuntime().wrap(function d(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,b.getVisitorWarehouseAudience(a);case 2:return c.abrupt("return",c.sent);case 3:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}(),[b]);return{getVisitorWarehouseAudience:c}}
2
+ //# sourceMappingURL=useVisitorWarehouseAudience.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVisitorWarehouseAudience.js","names":["useVisitorWarehouseAudience","a","useKameleoon","client","getVisitorWarehouseAudience","useCallback","_asyncToGenerator","_regeneratorRuntime","mark","c","params","wrap","d","prev","next","abrupt","sent","stop","b","apply","arguments"],"sources":["../src/useVisitorWarehouseAudience.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\nimport {\n GetVisitorWarehouseAudienceParamsType,\n CustomData,\n} from '@kameleoon/javascript-sdk-core';\n\nexport interface IVisitorWarehouseAudienceHookResult {\n /**\n * An asynchronous method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences\n * which is stored for specified visitorCode on a remote Kameleoon server\n * Retrieved data will be added to storage under the specified `customDataIndex`\n *\n * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details\n *\n * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getVisitorWarehouseAudience: ({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;\n}\n\n/**\n * A React Hook that returns asynchronous `getVisitorWarehouseAudience` function which retrieves warehouse audiences data\n *\n * @returns {IVisitorWarehouseAudienceHookResult} an object containing the `getVisitorWarehouseAudience` function.\n */\nexport function useVisitorWarehouseAudience(): IVisitorWarehouseAudienceHookResult {\n const { client } = useKameleoon();\n\n const getVisitorWarehouseAudience = useCallback(\n async (\n params: GetVisitorWarehouseAudienceParamsType,\n ): Promise<CustomData | null> => {\n return await client.getVisitorWarehouseAudience(params);\n },\n [client],\n );\n\n return {\n getVisitorWarehouseAudience,\n };\n}\n"],"mappings":"k2OAkCO,QAAS,CAAAA,2BAA2BA,CAAA,CAAwC,KAAAC,CAAA,CAC9D,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAA2B,CAAG,GAAAC,kBAAW,iBAAAJ,CAAA,CAAAK,iBAAA,CAAAC,mBAAA,GAAAC,IAAA,CAC7C,SAAAC,EACEC,CAA6C,SAAAH,mBAAA,GAAAI,IAAA,UAAAC,EAAAH,CAAA,iBAAAA,CAAA,CAAAI,IAAA,CAAAJ,CAAA,CAAAK,IAAA,gBAAAL,CAAA,CAAAK,IAAA,GAEhCX,CAAM,CAACC,2BAA2B,CAACM,CAAM,CAAC,eAAAD,CAAA,CAAAM,MAAA,UAAAN,CAAA,CAAAO,IAAA,0BAAAP,CAAA,CAAAQ,IAAA,MAAAR,CAAA,EACxD,mBAAAS,CAAA,SAAAjB,CAAA,CAAAkB,KAAA,MAAAC,SAAA,MACD,CAACjB,CAAM,CAAC,CACT,CAED,MAAO,CACLC,2BAA2B,CAA3BA,CACF,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/react-sdk",
3
- "version": "7.5.4",
3
+ "version": "8.0.0",
4
4
  "description": "Kameleoon React SDK",
5
5
  "files": [
6
6
  "dist"
@@ -38,7 +38,7 @@
38
38
  "react": ">=16.8.0"
39
39
  },
40
40
  "dependencies": {
41
- "@kameleoon/javascript-sdk-core": "^2.2.0",
41
+ "@kameleoon/javascript-sdk-core": "^3.0.0",
42
42
  "react-native": "^0.71.4",
43
43
  "react-native-event-source-ts": "^1.0.2",
44
44
  "react-native-mmkv": "2.4.4",
@@ -1,21 +0,0 @@
1
- import { JSONType } from '@kameleoon/javascript-sdk-core';
2
- export interface IExperimentVariationDataHookResult {
3
- /**
4
- * Returns variation data in JSON format for the variation with `variationId`.
5
- *
6
- * @param {number} variationId - id of variation
7
- * @returns {JSONType} variation data in JSON format
8
- * @throws `KameleoonError` with one of the following `type` s:
9
- *
10
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
11
- * - `KameleoonException.JSONParse` - Couldn't pass JSON value.
12
- * - `KameleoonException.VariationNotFound` - No variation found for provided `variationId`
13
- */
14
- getExperimentVariationData: (variationId: number) => JSONType;
15
- }
16
- /**
17
- * A React Hook that returns `getExperimentVariationData` function which returns variation data in JSON format for the variation with `variationId`.
18
- *
19
- * @returns {IExperimentVariationDataHookResult} an object containing the `getExperimentVariationData` function.
20
- */
21
- export declare function useExperimentVariationData(): IExperimentVariationDataHookResult;
@@ -1,6 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useExperimentVariationData=useExperimentVariationData;var _react=require("react"),_useKameleoon2=require("./useKameleoon");/**
2
- * A React Hook that returns `getExperimentVariationData` function which returns variation data in JSON format for the variation with `variationId`.
3
- *
4
- * @returns {IExperimentVariationDataHookResult} an object containing the `getExperimentVariationData` function.
5
- */function useExperimentVariationData(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){return b.getExperimentVariationData(a)},[b]);return{getExperimentVariationData:c}}
6
- //# sourceMappingURL=useExperimentVariationData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useExperimentVariationData.js","names":["useExperimentVariationData","a","useKameleoon","client","getExperimentVariationData","useCallback","variationId"],"sources":["../src/useExperimentVariationData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { JSONType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IExperimentVariationDataHookResult {\n /**\n * Returns variation data in JSON format for the variation with `variationId`.\n *\n * @param {number} variationId - id of variation\n * @returns {JSONType} variation data in JSON format\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value.\n * - `KameleoonException.VariationNotFound` - No variation found for provided `variationId`\n */\n getExperimentVariationData: (variationId: number) => JSONType;\n}\n\n/**\n * A React Hook that returns `getExperimentVariationData` function which returns variation data in JSON format for the variation with `variationId`.\n *\n * @returns {IExperimentVariationDataHookResult} an object containing the `getExperimentVariationData` function.\n */\nexport function useExperimentVariationData(): IExperimentVariationDataHookResult {\n const { client } = useKameleoon();\n\n const getExperimentVariationData = useCallback(\n (variationId: number): JSONType => {\n return client.getExperimentVariationData(variationId);\n },\n [client],\n );\n\n return {\n getExperimentVariationData,\n };\n}\n"],"mappings":"uMAmBA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,0BAA0BA,CAAA,CAAuC,KAAAC,CAAA,CAC5D,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAA0B,CAAG,GAAAC,kBAAW,EAC5C,SAACC,CAAmB,CAAe,CACjC,MAAO,CAAAH,CAAM,CAACC,0BAA0B,CAACE,CAAW,CACtD,CAAC,CACD,CAACH,CAAM,CAAC,CACT,CAED,MAAO,CACLC,0BAA0B,CAA1BA,CACF,CACF"}
@@ -1,18 +0,0 @@
1
- import { ExperimentType } from '@kameleoon/javascript-sdk-core';
2
- export interface IExperimentsHookResult {
3
- /**
4
- * Returns a list of experiments stored in the client configuration.
5
- *
6
- * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields.
7
- * @throws `KameleoonError` with one of the following `type` s:
8
- *
9
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
10
- */
11
- getExperiments: () => ExperimentType[];
12
- }
13
- /**
14
- * A React Hook that returns `getExperiments` function which returns a list of experiments.
15
- *
16
- * @returns {IExperimentsHookResult} an object containing the `getExperiments` function.
17
- */
18
- export declare function useExperiments(): IExperimentsHookResult;
@@ -1,6 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useExperiments=useExperiments;var _react=require("react"),_useKameleoon2=require("./useKameleoon");/**
2
- * A React Hook that returns `getExperiments` function which returns a list of experiments.
3
- *
4
- * @returns {IExperimentsHookResult} an object containing the `getExperiments` function.
5
- */function useExperiments(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(){return b.getExperiments()},[b]);return{getExperiments:c}}
6
- //# sourceMappingURL=useExperiments.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useExperiments.js","names":["useExperiments","a","useKameleoon","client","getExperiments","useCallback"],"sources":["../src/useExperiments.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { ExperimentType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IExperimentsHookResult {\n /**\n * Returns a list of experiments stored in the client configuration.\n *\n * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n * \n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n */\n getExperiments: () => ExperimentType[];\n}\n\n/**\n * A React Hook that returns `getExperiments` function which returns a list of experiments.\n *\n * @returns {IExperimentsHookResult} an object containing the `getExperiments` function.\n */\nexport function useExperiments(): IExperimentsHookResult {\n const { client } = useKameleoon();\n\n const getExperiments = useCallback((): ExperimentType[] => {\n return client.getExperiments();\n }, [client]);\n\n return {\n getExperiments,\n };\n}\n"],"mappings":"+KAgBA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,cAAcA,CAAA,CAA2B,KAAAC,CAAA,CACpC,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAc,CAAG,GAAAC,kBAAW,EAAC,UAAwB,CACzD,MAAO,CAAAF,CAAM,CAACC,cAAc,EAC9B,CAAC,CAAE,CAACD,CAAM,CAAC,CAAC,CAEZ,MAAO,CACLC,cAAc,CAAdA,CACF,CACF"}
@@ -1,19 +0,0 @@
1
- export interface IFlushDataHookResult {
2
- /**
3
- * Takes visitor associated kameleoon data and sends the data tracking request with collected data sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks.
4
- * If no visitor is passed, then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input
5
- * execution starts with sending all previously failed tracking requests which were stored locally during the offline mode and then proceeds further.
6
- *
7
- * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length.
8
- * @throws `KameleoonError` with one of the following `type` s:
9
- *
10
- * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
11
- * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
12
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
13
- */
14
- flushData: (visitorCode: string) => void;
15
- }
16
- /**
17
- * @deprecated Use `useFlush` instead.
18
- */
19
- export declare function useFlushData(): IFlushDataHookResult;
@@ -1,4 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFlushData=useFlushData;var _react=require("react"),_useKameleoon2=require("./useKameleoon");/**
2
- * @deprecated Use `useFlush` instead.
3
- */function useFlushData(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a){b.flush(a)},[b]);return{flushData:c}}
4
- //# sourceMappingURL=useFlushData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFlushData.js","names":["useFlushData","a","useKameleoon","client","flushData","useCallback","visitorCode","flush"],"sources":["../src/useFlushData.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IFlushDataHookResult {\n /**\n * Takes visitor associated kameleoon data and sends the data tracking request with collected data sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks.\n * If no visitor is passed, then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * execution starts with sending all previously failed tracking requests which were stored locally during the offline mode and then proceeds further.\n *\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n */\n flushData: (visitorCode: string) => void;\n}\n\n/**\n * @deprecated Use `useFlush` instead.\n */\nexport function useFlushData(): IFlushDataHookResult {\n const { client } = useKameleoon();\n\n const flushData = useCallback(\n (visitorCode: string): void => {\n client.flush(visitorCode);\n },\n [client],\n );\n\n return {\n flushData,\n };\n}\n"],"mappings":"2KAmBA;AACA;AACA,GACO,QAAS,CAAAA,YAAYA,CAAA,CAAyB,KAAAC,CAAA,CAChC,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAS,CAAG,GAAAC,kBAAW,EAC3B,SAACC,CAAmB,CAAW,CAC7BH,CAAM,CAACI,KAAK,CAACD,CAAW,CAC1B,CAAC,CACD,CAACH,CAAM,CAAC,CACT,CAED,MAAO,CACLC,SAAS,CAATA,CACF,CACF"}
@@ -1,24 +0,0 @@
1
- export interface ITriggerExperimentHookResult {
2
- /**
3
- * Triggers experiment by assigning the variation to the user with `visitorCode`, if the variation is already assigned just returns it's id. Note: returned id `0` indicates default variation. At the same time executes `flushData` without sending extra request.
4
- *
5
- * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.
6
- * @param {number} experimentId - id of experiment running for the current visitor.
7
- * @returns {number} associated variationId which is successfully searched/assigned.
8
- * @throws `KameleoonError` with one of the following `type` s:
9
- *
10
- * - `KameleoonException.ExperimentConfigurationNotFound` No configuration found for provided `experimentId`.
11
- * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded.
12
- * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
13
- * - `KameleoonException.StorageRead` Couldn't find associated experiment by provided `experimentId` and `visitorCode` inside the storage.
14
- * - `KameleoonException.NotTargeted` Current visitor is not targeted.
15
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
16
- */
17
- triggerExperiment: (visitorCode: string, experimentId: number) => number;
18
- }
19
- /**
20
- * A React Hook that returns `triggerExperiment` function which triggers experiment.
21
- *
22
- * @returns {ITriggerExperimentHookResult} an object containing the `triggerExperiment` function.
23
- */
24
- export declare function useTriggerExperiment(): ITriggerExperimentHookResult;
@@ -1,6 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useTriggerExperiment=useTriggerExperiment;var _react=require("react"),_useKameleoon2=require("./useKameleoon");/**
2
- * A React Hook that returns `triggerExperiment` function which triggers experiment.
3
- *
4
- * @returns {ITriggerExperimentHookResult} an object containing the `triggerExperiment` function.
5
- */function useTriggerExperiment(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a,c){return b.triggerExperiment(a,c)},[b]);return{triggerExperiment:c}}
6
- //# sourceMappingURL=useTriggerExperiment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTriggerExperiment.js","names":["useTriggerExperiment","a","useKameleoon","client","triggerExperiment","useCallback","visitorCode","experimentId"],"sources":["../src/useTriggerExperiment.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface ITriggerExperimentHookResult {\n /**\n * Triggers experiment by assigning the variation to the user with `visitorCode`, if the variation is already assigned just returns it's id. Note: returned id `0` indicates default variation. At the same time executes `flushData` without sending extra request.\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @param {number} experimentId - id of experiment running for the current visitor.\n * @returns {number} associated variationId which is successfully searched/assigned.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.ExperimentConfigurationNotFound` No configuration found for provided `experimentId`.\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageRead` Couldn't find associated experiment by provided `experimentId` and `visitorCode` inside the storage.\n * - `KameleoonException.NotTargeted` Current visitor is not targeted.\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n */\n triggerExperiment: (visitorCode: string, experimentId: number) => number;\n}\n\n/**\n * A React Hook that returns `triggerExperiment` function which triggers experiment.\n *\n * @returns {ITriggerExperimentHookResult} an object containing the `triggerExperiment` function.\n */\nexport function useTriggerExperiment(): ITriggerExperimentHookResult {\n const { client } = useKameleoon();\n\n const triggerExperiment = useCallback(\n (visitorCode: string, experimentId: number): number => {\n return client.triggerExperiment(visitorCode, experimentId);\n },\n [client],\n );\n\n return {\n triggerExperiment,\n };\n}\n"],"mappings":"2LAsBA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,oBAAoBA,CAAA,CAAiC,KAAAC,CAAA,CAChD,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAiB,CAAG,GAAAC,kBAAW,EACnC,SAACC,CAAmB,CAAEC,CAAoB,CAAa,CACrD,MAAO,CAAAJ,CAAM,CAACC,iBAAiB,CAACE,CAAW,CAAEC,CAAY,CAC3D,CAAC,CACD,CAACJ,CAAM,CAAC,CACT,CAED,MAAO,CACLC,iBAAiB,CAAjBA,CACF,CACF"}
@@ -1,22 +0,0 @@
1
- import { ExperimentType } from '@kameleoon/javascript-sdk-core';
2
- export interface IVisitorExperimentsHookResult {
3
- /**
4
- * Returns a list of experiments that the visitor with `visitorCode` is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated if the experiment will be triggered).
5
- *
6
- * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.
7
- * @param {boolean | undefined} isAllocated - boolean value indicating that only experiments *allocated* for visitor will be returned. Default value is `true`.
8
- * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields.
9
- * @throws `KameleoonError` with one of the following `type` s:
10
- *
11
- * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.
12
- * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
13
- * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.
14
- */
15
- getVisitorExperiments: (visitorCode: string, isAllocated?: boolean) => ExperimentType[];
16
- }
17
- /**
18
- * A React Hook that returns `getVisitorExperiments` function which returns a list of experiments that the visitor with `visitorCode` is targeted by.
19
- *
20
- * @returns {IVisitorExperimentsHookResult} an object containing the `getVisitorExperiments` function.
21
- */
22
- export declare function useVisitorExperiments(): IVisitorExperimentsHookResult;
@@ -1,6 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useVisitorExperiments=useVisitorExperiments;var _react=require("react"),_useKameleoon2=require("./useKameleoon");/**
2
- * A React Hook that returns `getVisitorExperiments` function which returns a list of experiments that the visitor with `visitorCode` is targeted by.
3
- *
4
- * @returns {IVisitorExperimentsHookResult} an object containing the `getVisitorExperiments` function.
5
- */function useVisitorExperiments(){var a=(0,_useKameleoon2.useKameleoon)(),b=a.client,c=(0,_react.useCallback)(function(a,c){return b.getVisitorExperiments(a,c)},[b]);return{getVisitorExperiments:c}}
6
- //# sourceMappingURL=useVisitorExperiments.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useVisitorExperiments.js","names":["useVisitorExperiments","a","useKameleoon","client","getVisitorExperiments","useCallback","visitorCode","isAllocated"],"sources":["../src/useVisitorExperiments.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { ExperimentType } from '@kameleoon/javascript-sdk-core';\nimport { useKameleoon } from './useKameleoon';\n\nexport interface IVisitorExperimentsHookResult {\n /**\n * Returns a list of experiments that the visitor with `visitorCode` is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated if the experiment will be triggered).\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length.\n * @param {boolean | undefined} isAllocated - boolean value indicating that only experiments *allocated* for visitor will be returned. Default value is `true`.\n * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded.\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`.\n */\n getVisitorExperiments: (\n visitorCode: string,\n isAllocated?: boolean,\n ) => ExperimentType[];\n}\n\n/**\n * A React Hook that returns `getVisitorExperiments` function which returns a list of experiments that the visitor with `visitorCode` is targeted by.\n *\n * @returns {IVisitorExperimentsHookResult} an object containing the `getVisitorExperiments` function.\n */\nexport function useVisitorExperiments(): IVisitorExperimentsHookResult {\n const { client } = useKameleoon();\n\n const getVisitorExperiments = useCallback(\n (visitorCode: string, isAllocated?: boolean): ExperimentType[] => {\n return client.getVisitorExperiments(visitorCode, isAllocated);\n },\n [client],\n );\n\n return {\n getVisitorExperiments,\n };\n}\n"],"mappings":"6LAuBA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAA,qBAAqBA,CAAA,CAAkC,KAAAC,CAAA,CAClD,GAAAC,2BAAY,GAAE,CAAzBC,CAAM,CAAAF,CAAA,CAANE,MAAM,CAERC,CAAqB,CAAG,GAAAC,kBAAW,EACvC,SAACC,CAAmB,CAAEC,CAAqB,CAAuB,CAChE,MAAO,CAAAJ,CAAM,CAACC,qBAAqB,CAACE,CAAW,CAAEC,CAAW,CAC9D,CAAC,CACD,CAACJ,CAAM,CAAC,CACT,CAED,MAAO,CACLC,qBAAqB,CAArBA,CACF,CACF"}