@kameleoon/javascript-sdk-core 3.2.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clientConfiguration/clientConfiguration.d.ts +2 -2
- package/dist/clientConfiguration/clientConfiguration.js +1 -1
- package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
- package/dist/clientConfiguration/types.d.ts +2 -2
- package/dist/clientConfiguration/types.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kameleoonClient.d.ts +15 -27
- package/dist/kameleoonClient.js +1 -1
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonData/dataManager.js +1 -1
- package/dist/kameleoonData/dataManager.js.map +1 -1
- package/dist/kameleoonData/dataProcessor.js +1 -1
- package/dist/kameleoonData/dataProcessor.js.map +1 -1
- package/dist/kameleoonError/constants.js +1 -1
- package/dist/kameleoonError/constants.js.map +1 -1
- package/dist/kameleoonUtils.js +1 -1
- package/dist/kameleoonUtils.js.map +1 -1
- package/dist/requester/constants.d.ts +3 -1
- package/dist/requester/constants.js +1 -1
- package/dist/requester/constants.js.map +1 -1
- package/dist/requester/index.d.ts +2 -2
- package/dist/requester/index.js +1 -1
- package/dist/requester/index.js.map +1 -1
- package/dist/requester/requester.d.ts +4 -4
- package/dist/requester/requester.js +1 -1
- package/dist/requester/requester.js.map +1 -1
- package/dist/requester/types.d.ts +11 -7
- package/dist/requester/types.js +1 -1
- package/dist/requester/types.js.map +1 -1
- package/dist/storage/types.d.ts +5 -1
- package/dist/storage/types.js.map +1 -1
- package/dist/targeting/conditions/targetFeatureFlag.js +1 -1
- package/dist/targeting/conditions/targetFeatureFlag.js.map +1 -1
- package/dist/types.d.ts +26 -48
- package/dist/types.js.map +1 -1
- package/dist/utilities/types.d.ts +7 -0
- package/dist/utilities/types.js.map +1 -1
- package/dist/utilities/utilities.d.ts +5 -9
- package/dist/utilities/utilities.js +1 -1
- package/dist/utilities/utilities.js.map +1 -1
- package/dist/variationConfiguration/types.d.ts +6 -1
- package/dist/variationConfiguration/types.js.map +1 -1
- package/dist/variationConfiguration/variationConfiguration.d.ts +11 -1
- package/dist/variationConfiguration/variationConfiguration.js +1 -1
- package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
- package/dist/visitorCodeManager/index.d.ts +1 -0
- package/dist/visitorCodeManager/index.js +2 -0
- package/dist/visitorCodeManager/index.js.map +1 -0
- package/dist/visitorCodeManager/visitorCodeManager.d.ts +14 -0
- package/dist/visitorCodeManager/visitorCodeManager.js +2 -0
- package/dist/visitorCodeManager/visitorCodeManager.js.map +1 -0
- package/package.json +1 -1
- package/dist/cookieManager/cookieManager.d.ts +0 -16
- package/dist/cookieManager/cookieManager.js +0 -2
- package/dist/cookieManager/cookieManager.js.map +0 -1
- package/dist/cookieManager/index.d.ts +0 -1
- package/dist/cookieManager/index.js +0 -2
- package/dist/cookieManager/index.js.map +0 -1
|
@@ -25,8 +25,8 @@ export declare class ClientConfiguration implements IClientConfiguration {
|
|
|
25
25
|
private externalClientConfiguration?;
|
|
26
26
|
private mappedRules;
|
|
27
27
|
private dataManager;
|
|
28
|
-
private
|
|
29
|
-
constructor({ settings, storage, requester, dataManager, externalClientConfiguration, offlineTrackingStorage, externalEventSource,
|
|
28
|
+
private visitorCodeManager;
|
|
29
|
+
constructor({ settings, storage, requester, dataManager, externalClientConfiguration, offlineTrackingStorage, externalEventSource, externalVisitorCodeManager, }: ClientConfigurationParametersType);
|
|
30
30
|
initialize(useCache?: boolean): Promise<Result<void, KameleoonError>>;
|
|
31
31
|
private cleanupHandlers;
|
|
32
32
|
private handleExternalUpdates;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientConfiguration=void 0;var _tsRes=require("ts-res"),_eventSource=require("../eventSource"),_constants=require("./constants"),_types=require("./types"),_utilities=require("../utilities");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)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}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 _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ClientConfiguration=function(){function a(b){var c=b.settings,d=b.storage,e=b.requester,f=b.dataManager,g=b.externalClientConfiguration,h=b.offlineTrackingStorage,i=b.externalEventSource,j=b.externalCookieManager;_classCallCheck(this,a),_defineProperty(this,"configurationUpdateCallback",void 0),_defineProperty(this,"updateConfigurationIntervalId",null),_defineProperty(this,"updateType",_types.UpdateType.Idle),_defineProperty(this,"configurationData",_constants.DEFAULT_CONFIGURATION_DATA),_defineProperty(this,"settings",void 0),_defineProperty(this,"lastUpdate",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"externalEventSource",void 0),_defineProperty(this,"externalClientConfiguration",void 0),_defineProperty(this,"mappedRules",new Map),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"cookieManager",void 0),this.requester=e,this.settings=c,this.lastUpdate=new Date,this.storage=d,this.dataManager=f,this.readStorageData(),this.externalClientConfiguration=g,this.offlineTrackingStorage=h,this.externalEventSource=i,this.cookieManager=j}return _createClass(a,[{key:"initialize",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f;return _regeneratorRuntime().wrap(function g(b){for(;1;)switch(b.prev=b.next){case 0:if(c=!!this.externalClientConfiguration,d=this.checkShouldUpdate(c),!d){b.next=11;break}return b.next=5,this.updateClientConfiguration({useCache:a});case 5:if(e=b.sent,e.ok){b.next=8;break}return b.abrupt("return",e);case 8:if(f=e.data,!f){b.next=11;break}return b.abrupt("return",(0,_tsRes.Ok)());case 11:if(!c){b.next=14;break}return this.handleExternalUpdates(),b.abrupt("return",(0,_tsRes.Ok)());case 14:if(this.updateType!==_types.UpdateType.RealTime||this.eventSource){b.next=18;break}return this.updateType=_types.UpdateType.Idle,this.handleRealTimeUpdates(a),b.abrupt("return",(0,_tsRes.Ok)());case 18:return this.updateType===_types.UpdateType.Polling&&this.handlePollingUpdates(a),b.abrupt("return",(0,_tsRes.Ok)());case 20:case"end":return b.stop();}},b,this)}));return a}()},{key:"cleanupHandlers",value:function cleanupHandlers(){this.eventSource&&this.eventSource.close(),this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId)}},{key:"handleExternalUpdates",value:function handleExternalUpdates(){this.cleanupHandlers(),this.configurationData=this.externalClientConfiguration}},{key:"handleRealTimeUpdates",value:function handleRealTimeUpdates(a){var b=this;this.cleanupHandlers(),this.eventSource=new _eventSource.ExternalEventSource(this.settings.siteCode,this.externalEventSource);var c=function updateEventCallback(c){b.updateClientConfiguration({useCache:a,timestamp:c}).then(function(a){a.ok&&b.configurationUpdateCallback&&b.configurationUpdateCallback()})};this.eventSource.open(c)}},{key:"handlePollingUpdates",value:function handlePollingUpdates(a){var b=this;this.cleanupHandlers();try{this.updateConfigurationIntervalId=setInterval(function(){return b.updateClientConfiguration.bind(b)({useCache:a})},this.settings.updateInterval)}catch(a){throw this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId),a}}},{key:"onConfigurationUpdate",value:function onConfigurationUpdate(a){this.configurationUpdateCallback=a}},{key:"featureFlags",get:function get(){return this.configurationData.featureFlags}},{key:"configuration",get:function get(){return this.configurationData.configuration}},{key:"segments",get:function get(){var a=new Map;return this.featureFlags.forEach(function(b){b.rules.forEach(function(b){b.segment&&!a.has(b.segment.id)&&a.set(b.segment.id,b.segment)})}),a}},{key:"ruleMap",get:function get(){if(this.mappedRules.size)return this.mappedRules;var a,b=new Map,c=_createForOfIteratorHelper(this.featureFlags);try{for(c.s();!(a=c.n()).done;){var d,e=a.value,f=_createForOfIteratorHelper(e.rules);try{var g=function _loop(){var a=d.value,c=a.id,f=a.experimentId,g=a.variationByExposition,h=new Map;g.forEach(function(a){var b=a.variationKey,c=a.variationId;"number"==typeof c&&h.set(b,c)}),b.set(c,{featureId:e.id,experimentId:f,variations:h})};for(f.s();!(d=f.n()).done;)g()}catch(a){f.e(a)}finally{f.f()}}}catch(a){c.e(a)}finally{c.f()}return this.mappedRules=b,b}},{key:"isConsentRequired",get:function get(){return this.configuration.consentType===_types.ConsentType.Required}},{key:"hasAnyTargetedDeliveryRule",get:function get(){return this.featureFlags.some(function(a){return a.environmentEnabled&&a.rules.some(function(a){return a.type===_types.RuleType.TARGETED_DELIVERY})})}},{key:"checkShouldUpdate",value:function checkShouldUpdate(){var a=!!(0<arguments.length&&void 0!==arguments[0])&&arguments[0],b=this.configurationData,c=b.featureFlags,d=b.configuration,e=this.settings.updateInterval;if(a)return this.updateType=_types.UpdateType.Idle,!1;if(this.updateType=d.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,!c.length)return!0;var f=this.lastUpdate.getTime(),g=Date.now()-e;return f<g}},{key:"readStorageData",value:function readStorageData(){var a=this.storage.read();if(a.ok){var b=a.data,c=b.data,d=b.lastUpdate;this.configurationData=c,this.lastUpdate=new Date(Date.parse(d))}}},{key:"updateClientConfiguration",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function a(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o=arguments;return _regeneratorRuntime().wrap(function p(a){for(;1;)switch(a.prev=a.next){case 0:return b=0<o.length&&void 0!==o[0]?o[0]:{},c=b.useCache,d=void 0!==c&&c,e=b.timestamp,a.next=3,this.requester.getClientConfiguration(e);case 3:if(f=a.sent,f.ok){a.next=9;break}if(g=this.configurationData.featureFlags,!(d&&g.length)){a.next=8;break}return a.abrupt("return",(0,_tsRes.Ok)(!0));case 8:return a.abrupt("return",f);case 9:if(_utilities.Utilities.sendOfflineTracking({storage:this.offlineTrackingStorage,requester:this.requester}),h=f.data,i=h.configuration,j=h.customData,this.configurationData=f.data,null!==j&&void 0!==j&&j.length&&(this.dataManager.customDataIndexes=j),this.dataManager.clearTrees(),this.mappedRules.clear(),k=this.updateStorageData(),k.ok){a.next=18;break}return a.abrupt("return",k);case 18:if(l=i.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,m=l!==this.updateType,!m){a.next=24;break}return this.updateType=l,a.next=24,this.initialize(d);case 24:return n=this.isConsentRequired&&!this.hasAnyTargetedDeliveryRule,this.cookieManager.setConsentRequired(n),a.abrupt("return",(0,_tsRes.Ok)(m));case 27:case"end":return a.stop();}},a,this)}));return a}()},{key:"updateStorageData",value:function updateStorageData(){this.lastUpdate=new Date;var a={data:this.configurationData,lastUpdate:this.lastUpdate.toString()};return this.storage.write(a)}}]),a}();exports.ClientConfiguration=ClientConfiguration;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientConfiguration=void 0;var _tsRes=require("ts-res"),_eventSource=require("../eventSource"),_constants=require("./constants"),_types=require("./types"),_utilities=require("../utilities");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)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}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 _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ClientConfiguration=function(){function a(b){var c=b.settings,d=b.storage,e=b.requester,f=b.dataManager,g=b.externalClientConfiguration,h=b.offlineTrackingStorage,i=b.externalEventSource,j=b.externalVisitorCodeManager;_classCallCheck(this,a),_defineProperty(this,"configurationUpdateCallback",void 0),_defineProperty(this,"updateConfigurationIntervalId",null),_defineProperty(this,"updateType",_types.UpdateType.Idle),_defineProperty(this,"configurationData",_constants.DEFAULT_CONFIGURATION_DATA),_defineProperty(this,"settings",void 0),_defineProperty(this,"lastUpdate",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"externalEventSource",void 0),_defineProperty(this,"externalClientConfiguration",void 0),_defineProperty(this,"mappedRules",new Map),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"visitorCodeManager",void 0),this.requester=e,this.settings=c,this.lastUpdate=new Date,this.storage=d,this.dataManager=f,this.readStorageData(),this.externalClientConfiguration=g,this.offlineTrackingStorage=h,this.externalEventSource=i,this.visitorCodeManager=j}return _createClass(a,[{key:"initialize",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f;return _regeneratorRuntime().wrap(function g(b){for(;1;)switch(b.prev=b.next){case 0:if(c=!!this.externalClientConfiguration,d=this.checkShouldUpdate(c),!d){b.next=11;break}return b.next=5,this.updateClientConfiguration({useCache:a});case 5:if(e=b.sent,e.ok){b.next=8;break}return b.abrupt("return",e);case 8:if(f=e.data,!f){b.next=11;break}return b.abrupt("return",(0,_tsRes.Ok)());case 11:if(!c){b.next=14;break}return this.handleExternalUpdates(),b.abrupt("return",(0,_tsRes.Ok)());case 14:if(this.updateType!==_types.UpdateType.RealTime||this.eventSource){b.next=18;break}return this.updateType=_types.UpdateType.Idle,this.handleRealTimeUpdates(a),b.abrupt("return",(0,_tsRes.Ok)());case 18:return this.updateType===_types.UpdateType.Polling&&this.handlePollingUpdates(a),b.abrupt("return",(0,_tsRes.Ok)());case 20:case"end":return b.stop();}},b,this)}));return a}()},{key:"cleanupHandlers",value:function cleanupHandlers(){this.eventSource&&this.eventSource.close(),this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId)}},{key:"handleExternalUpdates",value:function handleExternalUpdates(){this.cleanupHandlers(),this.configurationData=this.externalClientConfiguration}},{key:"handleRealTimeUpdates",value:function handleRealTimeUpdates(a){var b=this;this.cleanupHandlers(),this.eventSource=new _eventSource.ExternalEventSource(this.settings.siteCode,this.externalEventSource);var c=function updateEventCallback(c){b.updateClientConfiguration({useCache:a,timestamp:c}).then(function(a){a.ok&&b.configurationUpdateCallback&&b.configurationUpdateCallback()})};this.eventSource.open(c)}},{key:"handlePollingUpdates",value:function handlePollingUpdates(a){var b=this;this.cleanupHandlers();try{this.updateConfigurationIntervalId=setInterval(function(){return b.updateClientConfiguration.bind(b)({useCache:a})},this.settings.updateInterval)}catch(a){throw this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId),a}}},{key:"onConfigurationUpdate",value:function onConfigurationUpdate(a){this.configurationUpdateCallback=a}},{key:"featureFlags",get:function get(){return this.configurationData.featureFlags}},{key:"configuration",get:function get(){return this.configurationData.configuration}},{key:"segments",get:function get(){var a=new Map;return this.featureFlags.forEach(function(b){b.rules.forEach(function(b){b.segment&&!a.has(b.segment.id)&&a.set(b.segment.id,b.segment)})}),a}},{key:"ruleMap",get:function get(){if(this.mappedRules.size)return this.mappedRules;var a,b=new Map,c=_createForOfIteratorHelper(this.featureFlags);try{for(c.s();!(a=c.n()).done;){var d,e=a.value,f=_createForOfIteratorHelper(e.rules);try{var g=function _loop(){var a=d.value,c=a.id,f=a.experimentId,g=a.variationByExposition,h=new Map;g.forEach(function(a){var b=a.variationKey,c=a.variationId;"number"==typeof c&&h.set(b,c)}),b.set(c,{featureId:e.id,experimentId:f,variations:h})};for(f.s();!(d=f.n()).done;)g()}catch(a){f.e(a)}finally{f.f()}}}catch(a){c.e(a)}finally{c.f()}return this.mappedRules=b,b}},{key:"isConsentRequired",get:function get(){return this.configuration.consentType===_types.ConsentType.Required}},{key:"hasAnyTargetedDeliveryRule",get:function get(){return this.featureFlags.some(function(a){return a.environmentEnabled&&a.rules.some(function(a){return a.type===_types.RuleType.TARGETED_DELIVERY})})}},{key:"checkShouldUpdate",value:function checkShouldUpdate(){var a=!!(0<arguments.length&&void 0!==arguments[0])&&arguments[0],b=this.configurationData,c=b.featureFlags,d=b.configuration,e=this.settings.updateInterval;if(a)return this.updateType=_types.UpdateType.Idle,!1;if(this.updateType=d.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,!c.length)return!0;var f=this.lastUpdate.getTime(),g=Date.now()-e;return f<g}},{key:"readStorageData",value:function readStorageData(){var a=this.storage.read();if(a.ok){var b=a.data,c=b.data,d=b.lastUpdate;this.configurationData=c,this.lastUpdate=new Date(Date.parse(d))}}},{key:"updateClientConfiguration",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function a(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o=arguments;return _regeneratorRuntime().wrap(function p(a){for(;1;)switch(a.prev=a.next){case 0:return b=0<o.length&&void 0!==o[0]?o[0]:{},c=b.useCache,d=void 0!==c&&c,e=b.timestamp,a.next=3,this.requester.getClientConfiguration(e);case 3:if(f=a.sent,f.ok){a.next=9;break}if(g=this.configurationData.featureFlags,!(d&&g.length)){a.next=8;break}return a.abrupt("return",(0,_tsRes.Ok)(!0));case 8:return a.abrupt("return",f);case 9:if(_utilities.Utilities.sendOfflineTracking({storage:this.offlineTrackingStorage,requester:this.requester}),h=f.data,i=h.configuration,j=h.customData,this.configurationData=f.data,null!==j&&void 0!==j&&j.length&&(this.dataManager.customDataIndexes=j),this.dataManager.clearTrees(),this.mappedRules.clear(),k=this.updateStorageData(),k.ok){a.next=18;break}return a.abrupt("return",k);case 18:if(l=i.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,m=l!==this.updateType,!m){a.next=24;break}return this.updateType=l,a.next=24,this.initialize(d);case 24:return n=this.isConsentRequired&&!this.hasAnyTargetedDeliveryRule,this.visitorCodeManager.setConsentRequired(n),a.abrupt("return",(0,_tsRes.Ok)(m));case 27:case"end":return a.stop();}},a,this)}));return a}()},{key:"updateStorageData",value:function updateStorageData(){this.lastUpdate=new Date;var a={data:this.configurationData,lastUpdate:this.lastUpdate.toString()};return this.storage.write(a)}}]),a}();exports.ClientConfiguration=ClientConfiguration;
|
|
2
2
|
//# sourceMappingURL=clientConfiguration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientConfiguration.js","names":["ClientConfiguration","a","b","settings","storage","requester","dataManager","externalClientConfiguration","offlineTrackingStorage","externalEventSource","externalCookieManager","_classCallCheck","_defineProperty","UpdateType","Idle","DEFAULT_CONFIGURATION_DATA","Map","lastUpdate","Date","readStorageData","cookieManager","_createClass","key","value","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","useCache","c","d","e","f","wrap","g","prev","next","isExternalConfiguration","shouldUpdate","checkShouldUpdate","updateClientConfiguration","updateResult","sent","ok","abrupt","isUpdateTypeToggled","data","Ok","handleExternalUpdates","updateType","RealTime","eventSource","handleRealTimeUpdates","Polling","handlePollingUpdates","stop","cleanupHandlers","close","updateConfigurationIntervalId","clearInterval","configurationData","ExternalEventSource","siteCode","updateEventCallback","timestamp","then","configurationUpdateCallback","open","setInterval","bind","updateInterval","err","onConfigurationUpdate","callback","get","featureFlags","configuration","segments","forEach","flag","rules","rule","segment","has","id","set","mappedRules","size","_createForOfIteratorHelper","s","n","done","featureFlag","_loop","experimentId","variationByExposition","variationMap","variationKey","variationId","featureId","variations","consentType","ConsentType","Required","some","environmentEnabled","type","RuleType","TARGETED_DELIVERY","skipChecks","length","realTimeUpdate","lastUpdateTime","getTime","updateWindowEdge","now","result","read","parse","h","i","j","k","l","m","o","p","getClientConfiguration","clientConfigurationResult","Utilities","sendOfflineTracking","customData","customDataIndexes","clearTrees","clear","updateStorageData","toggleUpdateType","initialize","consentRequired","isConsentRequired","hasAnyTargetedDeliveryRule","setConsentRequired","toString","write","exports"],"sources":["../../src/clientConfiguration/clientConfiguration.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError/kameleoonError';\nimport { ClientSettingsType } from 'src/clientSettings/types';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { SegmentType } from 'src/targeting';\nimport { IExternalStorage, ClientDataType } from 'src/storage';\nimport {\n ExternalEventSource,\n IEventSource,\n IExternalEventSourceConstructor,\n} from 'src/eventSource';\nimport { DEFAULT_CONFIGURATION_DATA } from './constants';\nimport {\n ClientConfigurationParametersType,\n ConfigurationDataType,\n ConfigurationType,\n ConsentType,\n FeatureFlagType,\n MappedRuleType,\n RuleType,\n UpdateClientConfigurationParameters,\n UpdateType,\n} from './types';\nimport { Utilities } from 'src/utilities';\nimport { OfflineTracking } from 'src/storage/types';\nimport { CookieManager } from 'src/cookieManager';\n\ninterface IClientConfiguration {\n initialize: (useCache?: boolean) => Promise<Result<void, KameleoonError>>;\n onConfigurationUpdate: (callback: () => void) => void;\n readonly featureFlags: FeatureFlagType[];\n readonly configuration: ConfigurationType;\n readonly segments: Map<string, SegmentType>;\n readonly ruleMap: Map<number, MappedRuleType>;\n}\n\nexport class ClientConfiguration implements IClientConfiguration {\n private configurationUpdateCallback?: () => void;\n private updateConfigurationIntervalId: NodeJS.Timer | null = null;\n private updateType: UpdateType = UpdateType.Idle;\n private configurationData: ConfigurationDataType = DEFAULT_CONFIGURATION_DATA;\n private settings: ClientSettingsType;\n private lastUpdate: Date;\n private storage: IExternalStorage<ClientDataType>;\n private offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n private requester: Requester;\n private eventSource?: IEventSource;\n private externalEventSource: IExternalEventSourceConstructor;\n private externalClientConfiguration?: ConfigurationDataType;\n private mappedRules: Map<number, MappedRuleType> = new Map();\n private dataManager: DataManager;\n private cookieManager: CookieManager;\n\n constructor({\n settings,\n storage,\n requester,\n dataManager,\n externalClientConfiguration,\n offlineTrackingStorage,\n externalEventSource,\n externalCookieManager,\n }: ClientConfigurationParametersType) {\n this.requester = requester;\n this.settings = settings;\n this.lastUpdate = new Date();\n this.storage = storage;\n this.dataManager = dataManager;\n this.readStorageData();\n this.externalClientConfiguration = externalClientConfiguration;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.externalEventSource = externalEventSource;\n this.cookieManager = externalCookieManager;\n }\n\n public async initialize(\n useCache?: boolean,\n ): Promise<Result<void, KameleoonError>> {\n const isExternalConfiguration = Boolean(this.externalClientConfiguration);\n const shouldUpdate = this.checkShouldUpdate(isExternalConfiguration);\n\n if (shouldUpdate) {\n const updateResult = await this.updateClientConfiguration({ useCache });\n\n if (!updateResult.ok) {\n return updateResult;\n }\n\n // --- Note ---\n // If update type is being toggled `initialize` will be called again\n // so we don't need to continue execution here\n const isUpdateTypeToggled = updateResult.data;\n\n if (isUpdateTypeToggled) {\n return Ok();\n }\n }\n\n if (isExternalConfiguration) {\n this.handleExternalUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.RealTime && !this.eventSource) {\n this.updateType = UpdateType.Idle;\n this.handleRealTimeUpdates(useCache);\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.Polling) {\n this.handlePollingUpdates(useCache);\n }\n\n return Ok();\n }\n\n private cleanupHandlers(): void {\n if (this.eventSource) {\n this.eventSource.close();\n }\n\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n }\n\n private handleExternalUpdates(): void {\n this.cleanupHandlers();\n\n this.configurationData = this.externalClientConfiguration!;\n }\n\n private handleRealTimeUpdates(useCache?: boolean): void {\n this.cleanupHandlers();\n\n this.eventSource = new ExternalEventSource(\n this.settings.siteCode,\n this.externalEventSource,\n );\n\n const updateEventCallback = (timestamp: number) => {\n this.updateClientConfiguration({ useCache, timestamp }).then(\n (updateResult) => {\n if (updateResult.ok && this.configurationUpdateCallback) {\n this.configurationUpdateCallback();\n }\n },\n );\n };\n\n this.eventSource.open(updateEventCallback);\n }\n\n private handlePollingUpdates(useCache?: boolean): void {\n // --- Note ---\n // If `initialize` is called again the interval will be cleared\n // so theoretically we will constantly defer config update\n // but `this.lastUpdate` with `checkShouldUpdate` will prevent that\n this.cleanupHandlers();\n\n // --- Note ---\n // Same as targeting data interval we don't want to make failed configuration\n // retrieval recoverable\n try {\n this.updateConfigurationIntervalId = setInterval(\n () => this.updateClientConfiguration.bind(this)({ useCache }),\n this.settings.updateInterval,\n );\n } catch (err) {\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n\n throw err;\n }\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n this.configurationUpdateCallback = callback;\n }\n\n get featureFlags(): FeatureFlagType[] {\n return this.configurationData.featureFlags;\n }\n\n get configuration(): ConfigurationType {\n return this.configurationData.configuration;\n }\n\n get segments(): Map<string, SegmentType> {\n const segments = new Map();\n\n this.featureFlags.forEach((flag) => {\n flag.rules.forEach((rule) => {\n if (rule.segment && !segments.has(rule.segment.id)) {\n segments.set(rule.segment.id, rule.segment);\n }\n });\n });\n\n return segments;\n }\n\n get ruleMap(): Map<number, MappedRuleType> {\n if (this.mappedRules.size) {\n return this.mappedRules;\n }\n\n const mappedRules = new Map<number, MappedRuleType>();\n\n for (const featureFlag of this.featureFlags) {\n for (const rule of featureFlag.rules) {\n const { id, experimentId, variationByExposition } = rule;\n const variationMap = new Map<string, number>();\n\n variationByExposition.forEach(({ variationKey, variationId }) => {\n if (typeof variationId === 'number') {\n variationMap.set(variationKey, variationId);\n }\n });\n\n mappedRules.set(id, {\n featureId: featureFlag.id,\n experimentId,\n variations: variationMap,\n });\n }\n }\n\n this.mappedRules = mappedRules;\n\n return mappedRules;\n }\n\n get isConsentRequired(): boolean {\n return this.configuration.consentType === ConsentType.Required;\n }\n\n get hasAnyTargetedDeliveryRule(): boolean {\n return this.featureFlags.some(\n (featureFlag) =>\n featureFlag.environmentEnabled &&\n featureFlag.rules.some(\n (rule) => rule.type === RuleType.TARGETED_DELIVERY,\n ),\n );\n }\n\n private checkShouldUpdate(skipChecks = false): boolean {\n const { featureFlags, configuration } = this.configurationData;\n const { updateInterval } = this.settings;\n\n // --- Note ---\n // Following `updateType` logic is done for client side\n // edge cases where we have previous campaigns on storage already, but we still want\n // to initialize SSE/Polling after page reload\n if (skipChecks) {\n this.updateType = UpdateType.Idle;\n\n return false;\n }\n\n this.updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n if (!featureFlags.length) {\n return true;\n }\n\n const lastUpdateTime = this.lastUpdate.getTime();\n const updateWindowEdge = Date.now() - updateInterval;\n\n return lastUpdateTime < updateWindowEdge;\n }\n\n private readStorageData(): void {\n const result = this.storage.read();\n\n if (result.ok) {\n const { data, lastUpdate } = result.data;\n\n this.configurationData = data;\n this.lastUpdate = new Date(Date.parse(lastUpdate));\n }\n }\n\n /**\n * Updates client configuration\n *\n * @param useCache - if true, will not update configuration if it is already present (for _offline_ mode)\n * @param timeStamp - timestamp for real-time configuration update\n *\n * @returns `true` if current update type should be toggled (SSE/Polling)\n */\n private async updateClientConfiguration({\n useCache = false,\n timestamp,\n }: UpdateClientConfigurationParameters = {}): Promise<\n Result<boolean, KameleoonError>\n > {\n const clientConfigurationResult =\n await this.requester.getClientConfiguration(timestamp);\n\n if (!clientConfigurationResult.ok) {\n const { featureFlags } = this.configurationData;\n\n if (useCache && featureFlags.length) {\n return Ok(true);\n }\n\n return clientConfigurationResult;\n }\n\n Utilities.sendOfflineTracking({\n storage: this.offlineTrackingStorage,\n requester: this.requester,\n });\n\n const { configuration, customData } = clientConfigurationResult.data;\n\n this.configurationData = clientConfigurationResult.data;\n\n if (customData?.length) {\n this.dataManager.customDataIndexes = customData;\n }\n\n this.dataManager.clearTrees();\n this.mappedRules.clear();\n\n const result = this.updateStorageData();\n\n if (!result.ok) {\n return result;\n }\n\n const updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n const toggleUpdateType = updateType !== this.updateType;\n\n if (toggleUpdateType) {\n this.updateType = updateType;\n await this.initialize(useCache);\n }\n\n // --- Note ---\n // Regarding GDPR policy we should set visitorCode if legal consent isn't required\n // or we have at least one Targeted Delivery rule in configuration\n const consentRequired =\n this.isConsentRequired && !this.hasAnyTargetedDeliveryRule;\n this.cookieManager.setConsentRequired(consentRequired);\n\n return Ok(toggleUpdateType);\n }\n\n private updateStorageData(): Result<void, KameleoonError> {\n this.lastUpdate = new Date();\n\n const data: ClientDataType = {\n data: this.configurationData,\n lastUpdate: this.lastUpdate.toString(),\n };\n\n return this.storage.write(data);\n }\n}\n"],"mappings":"4gTAqCa,CAAAA,mBAAmB,YAiB9B,SAAAC,EAAAC,CAAA,CASsC,IARpC,CAAAC,CAAQ,CAAAD,CAAA,CAARC,QAAQ,CACRC,CAAO,CAAAF,CAAA,CAAPE,OAAO,CACPC,CAAS,CAAAH,CAAA,CAATG,SAAS,CACTC,CAAW,CAAAJ,CAAA,CAAXI,WAAW,CACXC,CAA2B,CAAAL,CAAA,CAA3BK,2BAA2B,CAC3BC,CAAsB,CAAAN,CAAA,CAAtBM,sBAAsB,CACtBC,CAAmB,CAAAP,CAAA,CAAnBO,mBAAmB,CACnBC,CAAqB,CAAAR,CAAA,CAArBQ,qBAAqB,CAAAC,eAAA,MAAAV,CAAA,EAAAW,eAAA,4CAAAA,eAAA,sCAvBsC,IAAI,EAAAA,eAAA,mBAChCC,iBAAU,CAACC,IAAI,EAAAF,eAAA,0BACGG,qCAA0B,EAAAH,eAAA,yBAAAA,eAAA,2BAAAA,eAAA,wBAAAA,eAAA,uCAAAA,eAAA,0BAAAA,eAAA,4BAAAA,eAAA,oCAAAA,eAAA,4CAAAA,eAAA,oBAS1B,GAAI,CAAAI,GAAK,EAAAJ,eAAA,4BAAAA,eAAA,8BAc1D,IAAI,CAACP,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACF,QAAQ,CAAGA,CAAQ,CACxB,IAAI,CAACc,UAAU,CAAG,GAAI,CAAAC,IAAM,CAC5B,IAAI,CAACd,OAAO,CAAGA,CAAO,CACtB,IA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"version":3,"file":"clientConfiguration.js","names":["ClientConfiguration","a","b","settings","storage","requester","dataManager","externalClientConfiguration","offlineTrackingStorage","externalEventSource","externalVisitorCodeManager","_classCallCheck","_defineProperty","UpdateType","Idle","DEFAULT_CONFIGURATION_DATA","Map","lastUpdate","Date","readStorageData","visitorCodeManager","_createClass","key","value","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","useCache","c","d","e","f","wrap","g","prev","next","isExternalConfiguration","shouldUpdate","checkShouldUpdate","updateClientConfiguration","updateResult","sent","ok","abrupt","isUpdateTypeToggled","data","Ok","handleExternalUpdates","updateType","RealTime","eventSource","handleRealTimeUpdates","Polling","handlePollingUpdates","stop","cleanupHandlers","close","updateConfigurationIntervalId","clearInterval","configurationData","ExternalEventSource","siteCode","updateEventCallback","timestamp","then","configurationUpdateCallback","open","setInterval","bind","updateInterval","err","onConfigurationUpdate","callback","get","featureFlags","configuration","segments","forEach","flag","rules","rule","segment","has","id","set","mappedRules","size","_createForOfIteratorHelper","s","n","done","featureFlag","_loop","experimentId","variationByExposition","variationMap","variationKey","variationId","featureId","variations","consentType","ConsentType","Required","some","environmentEnabled","type","RuleType","TARGETED_DELIVERY","skipChecks","length","realTimeUpdate","lastUpdateTime","getTime","updateWindowEdge","now","result","read","parse","h","i","j","k","l","m","o","p","getClientConfiguration","clientConfigurationResult","Utilities","sendOfflineTracking","customData","customDataIndexes","clearTrees","clear","updateStorageData","toggleUpdateType","initialize","consentRequired","isConsentRequired","hasAnyTargetedDeliveryRule","setConsentRequired","toString","write","exports"],"sources":["../../src/clientConfiguration/clientConfiguration.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError/kameleoonError';\nimport { ClientSettingsType } from 'src/clientSettings/types';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { SegmentType } from 'src/targeting';\nimport { IExternalStorage, ClientDataType } from 'src/storage';\nimport {\n ExternalEventSource,\n IEventSource,\n IExternalEventSourceConstructor,\n} from 'src/eventSource';\nimport { DEFAULT_CONFIGURATION_DATA } from './constants';\nimport {\n ClientConfigurationParametersType,\n ConfigurationDataType,\n ConfigurationType,\n ConsentType,\n FeatureFlagType,\n MappedRuleType,\n RuleType,\n UpdateClientConfigurationParameters,\n UpdateType,\n} from './types';\nimport { Utilities } from 'src/utilities';\nimport { OfflineTracking } from 'src/storage/types';\nimport { VisitorCodeManager } from 'src/visitorCodeManager';\n\ninterface IClientConfiguration {\n initialize: (useCache?: boolean) => Promise<Result<void, KameleoonError>>;\n onConfigurationUpdate: (callback: () => void) => void;\n readonly featureFlags: FeatureFlagType[];\n readonly configuration: ConfigurationType;\n readonly segments: Map<string, SegmentType>;\n readonly ruleMap: Map<number, MappedRuleType>;\n}\n\nexport class ClientConfiguration implements IClientConfiguration {\n private configurationUpdateCallback?: () => void;\n private updateConfigurationIntervalId: NodeJS.Timer | null = null;\n private updateType: UpdateType = UpdateType.Idle;\n private configurationData: ConfigurationDataType = DEFAULT_CONFIGURATION_DATA;\n private settings: ClientSettingsType;\n private lastUpdate: Date;\n private storage: IExternalStorage<ClientDataType>;\n private offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n private requester: Requester;\n private eventSource?: IEventSource;\n private externalEventSource: IExternalEventSourceConstructor;\n private externalClientConfiguration?: ConfigurationDataType;\n private mappedRules: Map<number, MappedRuleType> = new Map();\n private dataManager: DataManager;\n private visitorCodeManager: VisitorCodeManager;\n\n constructor({\n settings,\n storage,\n requester,\n dataManager,\n externalClientConfiguration,\n offlineTrackingStorage,\n externalEventSource,\n externalVisitorCodeManager,\n }: ClientConfigurationParametersType) {\n this.requester = requester;\n this.settings = settings;\n this.lastUpdate = new Date();\n this.storage = storage;\n this.dataManager = dataManager;\n this.readStorageData();\n this.externalClientConfiguration = externalClientConfiguration;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.externalEventSource = externalEventSource;\n this.visitorCodeManager = externalVisitorCodeManager;\n }\n\n public async initialize(\n useCache?: boolean,\n ): Promise<Result<void, KameleoonError>> {\n const isExternalConfiguration = Boolean(this.externalClientConfiguration);\n const shouldUpdate = this.checkShouldUpdate(isExternalConfiguration);\n\n if (shouldUpdate) {\n const updateResult = await this.updateClientConfiguration({ useCache });\n\n if (!updateResult.ok) {\n return updateResult;\n }\n\n // --- Note ---\n // If update type is being toggled `initialize` will be called again\n // so we don't need to continue execution here\n const isUpdateTypeToggled = updateResult.data;\n\n if (isUpdateTypeToggled) {\n return Ok();\n }\n }\n\n if (isExternalConfiguration) {\n this.handleExternalUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.RealTime && !this.eventSource) {\n this.updateType = UpdateType.Idle;\n this.handleRealTimeUpdates(useCache);\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.Polling) {\n this.handlePollingUpdates(useCache);\n }\n\n return Ok();\n }\n\n private cleanupHandlers(): void {\n if (this.eventSource) {\n this.eventSource.close();\n }\n\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n }\n\n private handleExternalUpdates(): void {\n this.cleanupHandlers();\n\n this.configurationData = this.externalClientConfiguration!;\n }\n\n private handleRealTimeUpdates(useCache?: boolean): void {\n this.cleanupHandlers();\n\n this.eventSource = new ExternalEventSource(\n this.settings.siteCode,\n this.externalEventSource,\n );\n\n const updateEventCallback = (timestamp: number) => {\n this.updateClientConfiguration({ useCache, timestamp }).then(\n (updateResult) => {\n if (updateResult.ok && this.configurationUpdateCallback) {\n this.configurationUpdateCallback();\n }\n },\n );\n };\n\n this.eventSource.open(updateEventCallback);\n }\n\n private handlePollingUpdates(useCache?: boolean): void {\n // --- Note ---\n // If `initialize` is called again the interval will be cleared\n // so theoretically we will constantly defer config update\n // but `this.lastUpdate` with `checkShouldUpdate` will prevent that\n this.cleanupHandlers();\n\n // --- Note ---\n // Same as targeting data interval we don't want to make failed configuration\n // retrieval recoverable\n try {\n this.updateConfigurationIntervalId = setInterval(\n () => this.updateClientConfiguration.bind(this)({ useCache }),\n this.settings.updateInterval,\n );\n } catch (err) {\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n\n throw err;\n }\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n this.configurationUpdateCallback = callback;\n }\n\n get featureFlags(): FeatureFlagType[] {\n return this.configurationData.featureFlags;\n }\n\n get configuration(): ConfigurationType {\n return this.configurationData.configuration;\n }\n\n get segments(): Map<string, SegmentType> {\n const segments = new Map();\n\n this.featureFlags.forEach((flag) => {\n flag.rules.forEach((rule) => {\n if (rule.segment && !segments.has(rule.segment.id)) {\n segments.set(rule.segment.id, rule.segment);\n }\n });\n });\n\n return segments;\n }\n\n get ruleMap(): Map<number, MappedRuleType> {\n if (this.mappedRules.size) {\n return this.mappedRules;\n }\n\n const mappedRules = new Map<number, MappedRuleType>();\n\n for (const featureFlag of this.featureFlags) {\n for (const rule of featureFlag.rules) {\n const { id, experimentId, variationByExposition } = rule;\n const variationMap = new Map<string, number>();\n\n variationByExposition.forEach(({ variationKey, variationId }) => {\n if (typeof variationId === 'number') {\n variationMap.set(variationKey, variationId);\n }\n });\n\n mappedRules.set(id, {\n featureId: featureFlag.id,\n experimentId,\n variations: variationMap,\n });\n }\n }\n\n this.mappedRules = mappedRules;\n\n return mappedRules;\n }\n\n get isConsentRequired(): boolean {\n return this.configuration.consentType === ConsentType.Required;\n }\n\n get hasAnyTargetedDeliveryRule(): boolean {\n return this.featureFlags.some(\n (featureFlag) =>\n featureFlag.environmentEnabled &&\n featureFlag.rules.some(\n (rule) => rule.type === RuleType.TARGETED_DELIVERY,\n ),\n );\n }\n\n private checkShouldUpdate(skipChecks = false): boolean {\n const { featureFlags, configuration } = this.configurationData;\n const { updateInterval } = this.settings;\n\n // --- Note ---\n // Following `updateType` logic is done for client side\n // edge cases where we have previous campaigns on storage already, but we still want\n // to initialize SSE/Polling after page reload\n if (skipChecks) {\n this.updateType = UpdateType.Idle;\n\n return false;\n }\n\n this.updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n if (!featureFlags.length) {\n return true;\n }\n\n const lastUpdateTime = this.lastUpdate.getTime();\n const updateWindowEdge = Date.now() - updateInterval;\n\n return lastUpdateTime < updateWindowEdge;\n }\n\n private readStorageData(): void {\n const result = this.storage.read();\n\n if (result.ok) {\n const { data, lastUpdate } = result.data;\n\n this.configurationData = data;\n this.lastUpdate = new Date(Date.parse(lastUpdate));\n }\n }\n\n /**\n * Updates client configuration\n *\n * @param useCache - if true, will not update configuration if it is already present (for _offline_ mode)\n * @param timeStamp - timestamp for real-time configuration update\n *\n * @returns `true` if current update type should be toggled (SSE/Polling)\n */\n private async updateClientConfiguration({\n useCache = false,\n timestamp,\n }: UpdateClientConfigurationParameters = {}): Promise<\n Result<boolean, KameleoonError>\n > {\n const clientConfigurationResult =\n await this.requester.getClientConfiguration(timestamp);\n\n if (!clientConfigurationResult.ok) {\n const { featureFlags } = this.configurationData;\n\n if (useCache && featureFlags.length) {\n return Ok(true);\n }\n\n return clientConfigurationResult;\n }\n\n Utilities.sendOfflineTracking({\n storage: this.offlineTrackingStorage,\n requester: this.requester,\n });\n\n const { configuration, customData } = clientConfigurationResult.data;\n\n this.configurationData = clientConfigurationResult.data;\n\n if (customData?.length) {\n this.dataManager.customDataIndexes = customData;\n }\n\n this.dataManager.clearTrees();\n this.mappedRules.clear();\n\n const result = this.updateStorageData();\n\n if (!result.ok) {\n return result;\n }\n\n const updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n const toggleUpdateType = updateType !== this.updateType;\n\n if (toggleUpdateType) {\n this.updateType = updateType;\n await this.initialize(useCache);\n }\n\n // --- Note ---\n // Regarding GDPR policy we should set visitorCode if legal consent isn't required\n // or we have at least one Targeted Delivery rule in configuration\n const consentRequired =\n this.isConsentRequired && !this.hasAnyTargetedDeliveryRule;\n this.visitorCodeManager.setConsentRequired(consentRequired);\n\n return Ok(toggleUpdateType);\n }\n\n private updateStorageData(): Result<void, KameleoonError> {\n this.lastUpdate = new Date();\n\n const data: ClientDataType = {\n data: this.configurationData,\n lastUpdate: this.lastUpdate.toString(),\n };\n\n return this.storage.write(data);\n }\n}\n"],"mappings":"4gTAqCa,CAAAA,mBAAmB,YAiB9B,SAAAC,EAAAC,CAAA,CASsC,IARpC,CAAAC,CAAQ,CAAAD,CAAA,CAARC,QAAQ,CACRC,CAAO,CAAAF,CAAA,CAAPE,OAAO,CACPC,CAAS,CAAAH,CAAA,CAATG,SAAS,CACTC,CAAW,CAAAJ,CAAA,CAAXI,WAAW,CACXC,CAA2B,CAAAL,CAAA,CAA3BK,2BAA2B,CAC3BC,CAAsB,CAAAN,CAAA,CAAtBM,sBAAsB,CACtBC,CAAmB,CAAAP,CAAA,CAAnBO,mBAAmB,CACnBC,CAA0B,CAAAR,CAAA,CAA1BQ,0BAA0B,CAAAC,eAAA,MAAAV,CAAA,EAAAW,eAAA,4CAAAA,eAAA,sCAvBiC,IAAI,EAAAA,eAAA,mBAChCC,iBAAU,CAACC,IAAI,EAAAF,eAAA,0BACGG,qCAA0B,EAAAH,eAAA,yBAAAA,eAAA,2BAAAA,eAAA,wBAAAA,eAAA,uCAAAA,eAAA,0BAAAA,eAAA,4BAAAA,eAAA,oCAAAA,eAAA,4CAAAA,eAAA,oBAS1B,GAAI,CAAAI,GAAK,EAAAJ,eAAA,4BAAAA,eAAA,mCAc1D,IAAI,CAACP,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACF,QAAQ,CAAGA,CAAQ,CACxB,IAAI,CAACc,UAAU,CAAG,GAAI,CAAAC,IAAM,CAC5B,IAAI,CAACd,OAAO,CAAGA,CAAO,CACtB,IAAI,CAACE,WAAW,CAAGA,CAAW,CAC9B,IAAI,CAACa,eAAe,EAAE,CACtB,IAAI,CAACZ,2BAA2B,CAAGA,CAA2B,CAC9D,IAAI,CAACC,sBAAsB,CAAGA,CAAsB,CACpD,IAAI,CAACC,mBAAmB,CAAGA,CAAmB,CAC9C,IAAI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AA,iBAAApC,CAAA,CAAA4C,MAAA,UACLwE,CAAM,aAGTnE,CAAU,CAAG2B,CAAa,CAACmC,cAAc,CAC3CnG,iBAAU,CAACsC,QAAQ,CACnBtC,iBAAU,CAACyC,OAAO,CAEhBmF,CAAgB,CAAGvF,CAAU,GAAK,IAAI,CAACA,UAAU,EAEnDuF,CAAgB,EAAAxI,CAAA,CAAAoC,IAAA,gBAClB,KAAI,CAACa,UAAU,CAAGA,CAAU,CAAAjD,CAAA,CAAAoC,IAAA,IACtB,IAAI,CAACqG,UAAU,CAAC7G,CAAQ,CAAC,eAM3B,CAAA8G,CAAe,CACnB,IAAI,CAACC,iBAAiB,EAAI,CAAC,IAAI,CAACC,0BAA0B,CAC5D,IAAI,CAACzH,kBAAkB,CAAC0H,kBAAkB,CAACH,CAAe,CAAC,CAAA1I,CAAA,CAAA4C,MAAA,UAEpD,GAAAG,SAAE,EAACyF,CAAgB,CAAC,2BAAAxI,CAAA,CAAAuD,IAAA,MAAAvD,CAAA,OAC5B,UAAAA,CAAA,MAAAqB,GAAA,qBAAAC,KAAA,CAED,SAAAiH,kBAAA,CAA0D,CACxD,IAAI,CAACvH,UAAU,CAAG,GAAI,CAAAC,IAAM,CAE5B,GAAM,CAAA6B,CAAoB,CAAG,CAC3BA,IAAI,CAAE,IAAI,CAACc,iBAAiB,CAC5B5C,UAAU,CAAE,IAAI,CAACA,UAAU,CAAC8H,QAAQ,EACtC,CAAC,CAED,MAAO,KAAI,CAAC3I,OAAO,CAAC4I,KAAK,CAACjG,CAAI,CAChC,CAAC,IAAA9C,CAAA,IAAAgJ,OAAA,CAAAjJ,mBAAA,CAAAA,mBAAA"}
|
|
@@ -2,7 +2,7 @@ import { ClientSettingsType } from '../clientSettings';
|
|
|
2
2
|
import { IExternalEventSourceConstructor } from '../eventSource';
|
|
3
3
|
import { DataManager } from '../kameleoonData';
|
|
4
4
|
import { Requester } from '../requester';
|
|
5
|
-
import {
|
|
5
|
+
import { VisitorCodeManager } from '../visitorCodeManager';
|
|
6
6
|
import { ClientDataType, IExternalStorage } from '../storage';
|
|
7
7
|
import { OfflineTracking } from '../storage/types';
|
|
8
8
|
import { SegmentType } from '../targeting';
|
|
@@ -119,5 +119,5 @@ export type ClientConfigurationParametersType = {
|
|
|
119
119
|
offlineTrackingStorage: IExternalStorage<OfflineTracking>;
|
|
120
120
|
externalClientConfiguration?: ConfigurationDataType;
|
|
121
121
|
externalEventSource: IExternalEventSourceConstructor;
|
|
122
|
-
|
|
122
|
+
externalVisitorCodeManager: VisitorCodeManager;
|
|
123
123
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["UpdateType","Polling","RealTime","Idle","exports","RuleType","TARGETED_DELIVERY","EXPERIMENTATION","FeatureFlagSdkLanguageType","ANDROID","SWIFT","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACTJS","FeatureStatus","ACTIVATED","DEACTIVATED","SCHEDULED","CustomDataScope","Visit","Visitor","Page","ConsentType","Required","NotRequired"],"sources":["../../src/clientConfiguration/types.ts"],"sourcesContent":["import { ClientSettingsType } from 'src/clientSettings';\nimport { IExternalEventSourceConstructor } from 'src/eventSource';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","names":["UpdateType","Polling","RealTime","Idle","exports","RuleType","TARGETED_DELIVERY","EXPERIMENTATION","FeatureFlagSdkLanguageType","ANDROID","SWIFT","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACTJS","FeatureStatus","ACTIVATED","DEACTIVATED","SCHEDULED","CustomDataScope","Visit","Visitor","Page","ConsentType","Required","NotRequired"],"sources":["../../src/clientConfiguration/types.ts"],"sourcesContent":["import { ClientSettingsType } from 'src/clientSettings';\nimport { IExternalEventSourceConstructor } from 'src/eventSource';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { VisitorCodeManager } from 'src/visitorCodeManager';\nimport { ClientDataType, IExternalStorage } from 'src/storage';\nimport { OfflineTracking } from 'src/storage/types';\nimport { SegmentType } from 'src/targeting';\nimport { VariableType } from 'src/types';\n\nexport type UpdateClientConfigurationParameters = {\n timestamp?: number;\n useCache?: boolean;\n};\n\nexport type ScheduleType = {\n dateStart: string;\n dateEnd: string;\n};\n\nexport enum UpdateType {\n Polling,\n RealTime,\n Idle,\n}\n\nexport type JSONValue =\n | string\n | number\n | boolean\n | { [x: string]: JSONValue }\n | JSONValue[];\n\nexport type JSONType = Record<string | number | symbol, JSONValue> | null;\n\nexport enum RuleType {\n TARGETED_DELIVERY = 'TARGETED_DELIVERY',\n EXPERIMENTATION = 'EXPERIMENTATION',\n}\n\nexport enum FeatureFlagSdkLanguageType {\n ANDROID = 'ANDROID',\n SWIFT = 'SWIFT',\n JAVA = 'JAVA',\n CSHARP = 'CSHARP',\n NODEJS = 'NODEJS',\n PHP = 'PHP',\n RUBY = 'RUBY',\n GO = 'GO',\n FLUTTER = 'FLUTTER',\n REACTJS = 'REACTJS',\n}\n\nexport enum FeatureStatus {\n ACTIVATED = 'ACTIVATED',\n DEACTIVATED = 'DEACTIVATED',\n SCHEDULED = 'SCHEDULED',\n}\n\nexport enum CustomDataScope {\n Visit = 'VISIT',\n Visitor = 'VISITOR',\n Page = 'Page',\n}\n\nexport enum ConsentType {\n Required = 'REQUIRED',\n NotRequired = 'NOT_REQUIRED',\n}\n\nexport type DeviationType = {\n variationId: string;\n value: number;\n};\n\nexport type FeatureFlagType = {\n id: number;\n featureKey: string;\n environmentEnabled: boolean;\n variations: FeatureVariationType[];\n defaultVariationKey: string;\n rules: RuleItemType[];\n};\n\nexport type FeatureVariationType = {\n key: string;\n variables: FeatureVariableType[];\n};\n\nexport type FeatureVariableType = {\n key: string;\n type: VariableType;\n value: string | number | boolean;\n};\n\nexport type RuleItemType = {\n type: RuleType;\n id: number;\n respoolTime: number | null;\n order: number;\n exposition: number;\n experimentId: number;\n variationByExposition: VariationByExpositionType[];\n segment: SegmentType | null;\n};\n\nexport type MappedRuleType = {\n experimentId: number;\n featureId: number;\n // --- Note ---\n // Map<variationKey, variationId>\n variations: Map<string, number>;\n};\n\nexport type VariationByExpositionType = {\n variationKey: string;\n variationId: number;\n exposition: number;\n};\n\nexport type ConfigurationDataType = {\n featureFlags: FeatureFlagType[];\n configuration: ConfigurationType;\n customData: CustomDataConfigurationType[];\n};\n\nexport type CustomDataConfigurationType = {\n index: number;\n localOnly: boolean;\n isMappingIdentifier: boolean;\n scope: CustomDataScope;\n};\n\nexport type ConfigurationType = {\n realTimeUpdate: boolean;\n projectEnabled: boolean;\n consentType: ConsentType;\n};\n\nexport type ClientConfigurationParametersType = {\n settings: ClientSettingsType;\n storage: IExternalStorage<ClientDataType>;\n dataManager: DataManager;\n requester: Requester;\n offlineTrackingStorage: IExternalStorage<OfflineTracking>;\n externalClientConfiguration?: ConfigurationDataType;\n externalEventSource: IExternalEventSourceConstructor;\n externalVisitorCodeManager: VisitorCodeManager;\n};\n"],"mappings":"uNAoBY,CAAAA,UAAU,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAVA,CAAU,CAAAC,OAAA,cAAVD,CAAU,CAAVA,CAAU,CAAAE,QAAA,eAAVF,CAAU,CAAVA,CAAU,CAAAG,IAAA,WAAVH,CAAU,MAAAI,OAAA,CAAAJ,UAAA,CAAAA,UAAA,IAeV,CAAAK,QAAQ,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAC,iBAAA,qBAARD,CAAQ,CAAAE,eAAA,mBAARF,CAAQ,MAAAD,OAAA,CAAAC,QAAA,CAAAA,QAAA,IAKR,CAAAG,0BAA0B,UAA1BA,CAA0B,QAA1B,CAAAA,CAA0B,CAAAC,OAAA,WAA1BD,CAA0B,CAAAE,KAAA,SAA1BF,CAA0B,CAAAG,IAAA,QAA1BH,CAA0B,CAAAI,MAAA,UAA1BJ,CAA0B,CAAAK,MAAA,UAA1BL,CAA0B,CAAAM,GAAA,OAA1BN,CAA0B,CAAAO,IAAA,QAA1BP,CAA0B,CAAAQ,EAAA,MAA1BR,CAA0B,CAAAS,OAAA,WAA1BT,CAA0B,CAAAU,OAAA,WAA1BV,CAA0B,MAAAJ,OAAA,CAAAI,0BAAA,CAAAA,0BAAA,IAa1B,CAAAW,aAAa,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,SAAA,aAAbD,CAAa,CAAAE,WAAA,eAAbF,CAAa,CAAAG,SAAA,aAAbH,CAAa,MAAAf,OAAA,CAAAe,aAAA,CAAAA,aAAA,IAMb,CAAAI,eAAe,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,KAAA,SAAfD,CAAe,CAAAE,OAAA,WAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,MAAAnB,OAAA,CAAAmB,eAAA,CAAAA,eAAA,IAMf,CAAAI,WAAW,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,QAAA,YAAXD,CAAW,CAAAE,WAAA,gBAAXF,CAAW,MAAAvB,OAAA,CAAAuB,WAAA,CAAAA,WAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ export { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';
|
|
|
4
4
|
export { KameleoonException, KameleoonError } from './kameleoonError';
|
|
5
5
|
export { VisitorDataFiltersType } from './utilities';
|
|
6
6
|
export { FeatureFlagVariationsType, KameleoonStorageKey, StorageDataType, IExternalStorage, IExternalStorageConstructor, } from './storage';
|
|
7
|
-
export {
|
|
7
|
+
export { VisitorCodeManager } from './visitorCodeManager';
|
|
8
8
|
export { CookieParameter, VISITOR_CODE_LENGTH, SdkLanguageType, } from './constants';
|
|
9
9
|
export { JSONType, ConfigurationDataType } from './clientConfiguration';
|
|
10
|
-
export { Environment, VariableType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, ExternalPackageInfoType, TrackConversionParamsType, FeatureVariableResultType, RemoteVisitorDataParamsType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType,
|
|
10
|
+
export { Environment, VariableType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, ExternalPackageInfoType, FeatureFlagVariableType, TrackConversionParamsType, FeatureVariableResultType, RemoteVisitorDataParamsType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, Milliseconds, } from './types';
|
|
11
11
|
export { DEFAULT_CLEANUP_INTERVAL } from './kameleoonData';
|
|
12
12
|
export { ApplicationVersion, CustomData, Conversion, Device, Cookie, Browser, UserAgent, DeviceType, CookieType, GeolocationData, GeolocationInfoType, OperatingSystemType, OperatingSystem, BrowserType, PageView, KameleoonData, KameleoonDataType, PageViewParametersType, ConversionParametersType, ApplicationVersionDataType, } from './kameleoonData';
|
|
13
13
|
export { RealTimeEventType, IExternalEventSource, EventSourceOpenParametersType, IExternalEventSourceConstructor, } from './eventSource';
|
|
14
|
-
export { Header, HttpMethod, TrackParametersType, IExternalRequestDispatcher, } from './requester';
|
|
14
|
+
export { Header, HeadersType, HttpMethod, TrackParametersType, IExternalRequestDispatcher, } from './requester';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function get(){return _kameleoonData.ApplicationVersion}}),Object.defineProperty(exports,"ApplicationVersionDataType",{enumerable:!0,get:function get(){return _kameleoonData.ApplicationVersionDataType}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _kameleoonData.Browser}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function get(){return _kameleoonData.BrowserType}}),Object.defineProperty(exports,"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function get(){return _kameleoonData.ApplicationVersion}}),Object.defineProperty(exports,"ApplicationVersionDataType",{enumerable:!0,get:function get(){return _kameleoonData.ApplicationVersionDataType}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _kameleoonData.Browser}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function get(){return _kameleoonData.BrowserType}}),Object.defineProperty(exports,"ConfigurationDataType",{enumerable:!0,get:function get(){return _clientConfiguration.ConfigurationDataType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function get(){return _kameleoonData.Conversion}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function get(){return _kameleoonData.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function get(){return _kameleoonData.Cookie}}),Object.defineProperty(exports,"CookieParameter",{enumerable:!0,get:function get(){return _constants.CookieParameter}}),Object.defineProperty(exports,"CookieType",{enumerable:!0,get:function get(){return _kameleoonData.CookieType}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function get(){return _kameleoonData.CustomData}}),Object.defineProperty(exports,"DEFAULT_CLEANUP_INTERVAL",{enumerable:!0,get:function get(){return _kameleoonData.DEFAULT_CLEANUP_INTERVAL}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function get(){return _kameleoonData.Device}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function get(){return _kameleoonData.DeviceType}}),Object.defineProperty(exports,"Environment",{enumerable:!0,get:function get(){return _types.Environment}}),Object.defineProperty(exports,"Err",{enumerable:!0,get:function get(){return _tsRes.Err}}),Object.defineProperty(exports,"EventSourceOpenParametersType",{enumerable:!0,get:function get(){return _eventSource.EventSourceOpenParametersType}}),Object.defineProperty(exports,"ExternalPackageInfoType",{enumerable:!0,get:function get(){return _types.ExternalPackageInfoType}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function get(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureFlagVariableType",{enumerable:!0,get:function get(){return _types.FeatureFlagVariableType}}),Object.defineProperty(exports,"FeatureFlagVariationsType",{enumerable:!0,get:function get(){return _storage.FeatureFlagVariationsType}}),Object.defineProperty(exports,"FeatureVariableResultType",{enumerable:!0,get:function get(){return _types.FeatureVariableResultType}}),Object.defineProperty(exports,"GeolocationData",{enumerable:!0,get:function get(){return _kameleoonData.GeolocationData}}),Object.defineProperty(exports,"GeolocationInfoType",{enumerable:!0,get:function get(){return _kameleoonData.GeolocationInfoType}}),Object.defineProperty(exports,"GetFeatureFlagVariableParamsType",{enumerable:!0,get:function get(){return _types.GetFeatureFlagVariableParamsType}}),Object.defineProperty(exports,"GetVisitorWarehouseAudienceParamsType",{enumerable:!0,get:function get(){return _types.GetVisitorWarehouseAudienceParamsType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function get(){return _requester.Header}}),Object.defineProperty(exports,"HeadersType",{enumerable:!0,get:function get(){return _requester.HeadersType}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function get(){return _requester.HttpMethod}}),Object.defineProperty(exports,"IExternalEventSource",{enumerable:!0,get:function get(){return _eventSource.IExternalEventSource}}),Object.defineProperty(exports,"IExternalEventSourceConstructor",{enumerable:!0,get:function get(){return _eventSource.IExternalEventSourceConstructor}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function get(){return _requester.IExternalRequestDispatcher}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function get(){return _storage.IExternalStorage}}),Object.defineProperty(exports,"IExternalStorageConstructor",{enumerable:!0,get:function get(){return _storage.IExternalStorageConstructor}}),Object.defineProperty(exports,"IKameleoonCore",{enumerable:!0,get:function get(){return _kameleoonClient.IKameleoonClient}}),Object.defineProperty(exports,"InternalSDKConfigurationType",{enumerable:!0,get:function get(){return _types.InternalSDKConfigurationType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function get(){return _clientConfiguration.JSONType}}),Object.defineProperty(exports,"KameleoonCore",{enumerable:!0,get:function get(){return _kameleoonClient.KameleoonClient}}),Object.defineProperty(exports,"KameleoonCoreUtils",{enumerable:!0,get:function get(){return _kameleoonUtils.KameleoonUtils}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function get(){return _kameleoonData.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function get(){return _kameleoonData.KameleoonDataType}}),Object.defineProperty(exports,"KameleoonError",{enumerable:!0,get:function get(){return _kameleoonError.KameleoonError}}),Object.defineProperty(exports,"KameleoonException",{enumerable:!0,get:function get(){return _kameleoonError.KameleoonException}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function get(){return _storage.KameleoonStorageKey}}),Object.defineProperty(exports,"Milliseconds",{enumerable:!0,get:function get(){return _types.Milliseconds}}),Object.defineProperty(exports,"Ok",{enumerable:!0,get:function get(){return _tsRes.Ok}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function get(){return _kameleoonData.OperatingSystem}}),Object.defineProperty(exports,"OperatingSystemType",{enumerable:!0,get:function get(){return _kameleoonData.OperatingSystemType}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function get(){return _kameleoonData.PageView}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function get(){return _kameleoonData.PageViewParametersType}}),Object.defineProperty(exports,"RealTimeEventType",{enumerable:!0,get:function get(){return _eventSource.RealTimeEventType}}),Object.defineProperty(exports,"RemoteVisitorDataParamsType",{enumerable:!0,get:function get(){return _types.RemoteVisitorDataParamsType}}),Object.defineProperty(exports,"Result",{enumerable:!0,get:function get(){return _tsRes.Result}}),Object.defineProperty(exports,"SDKConfigurationType",{enumerable:!0,get:function get(){return _types.SDKConfigurationType}}),Object.defineProperty(exports,"SDKCoreParameters",{enumerable:!0,get:function get(){return _types.SDKCoreParameters}}),Object.defineProperty(exports,"SdkLanguageType",{enumerable:!0,get:function get(){return _constants.SdkLanguageType}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function get(){return _storage.StorageDataType}}),Object.defineProperty(exports,"TrackConversionParamsType",{enumerable:!0,get:function get(){return _types.TrackConversionParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function get(){return _requester.TrackParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function get(){return _kameleoonData.UserAgent}}),Object.defineProperty(exports,"VISITOR_CODE_LENGTH",{enumerable:!0,get:function get(){return _constants.VISITOR_CODE_LENGTH}}),Object.defineProperty(exports,"VariableType",{enumerable:!0,get:function get(){return _types.VariableType}}),Object.defineProperty(exports,"VisitorCodeManager",{enumerable:!0,get:function get(){return _visitorCodeManager.VisitorCodeManager}}),Object.defineProperty(exports,"VisitorDataFiltersType",{enumerable:!0,get:function get(){return _utilities.VisitorDataFiltersType}});var _tsRes=require("ts-res"),_kameleoonClient=require("./kameleoonClient"),_kameleoonUtils=require("./kameleoonUtils"),_kameleoonError=require("./kameleoonError"),_utilities=require("./utilities"),_storage=require("./storage"),_visitorCodeManager=require("./visitorCodeManager"),_constants=require("./constants"),_clientConfiguration=require("./clientConfiguration"),_types=require("./types"),_kameleoonData=require("./kameleoonData"),_eventSource=require("./eventSource"),_requester=require("./requester");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { Ok, Result, Err } from 'ts-res';\nexport {\n KameleoonClient as KameleoonCore,\n IKameleoonClient as IKameleoonCore,\n} from './kameleoonClient';\nexport { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';\nexport { KameleoonException, KameleoonError } from './kameleoonError';\nexport { VisitorDataFiltersType } from './utilities';\nexport {\n FeatureFlagVariationsType,\n KameleoonStorageKey,\n StorageDataType,\n IExternalStorage,\n IExternalStorageConstructor,\n} from './storage';\nexport {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { Ok, Result, Err } from 'ts-res';\nexport {\n KameleoonClient as KameleoonCore,\n IKameleoonClient as IKameleoonCore,\n} from './kameleoonClient';\nexport { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';\nexport { KameleoonException, KameleoonError } from './kameleoonError';\nexport { VisitorDataFiltersType } from './utilities';\nexport {\n FeatureFlagVariationsType,\n KameleoonStorageKey,\n StorageDataType,\n IExternalStorage,\n IExternalStorageConstructor,\n} from './storage';\nexport { VisitorCodeManager } from './visitorCodeManager';\nexport {\n CookieParameter,\n VISITOR_CODE_LENGTH,\n SdkLanguageType,\n} from './constants';\nexport { JSONType, ConfigurationDataType } from './clientConfiguration';\nexport {\n Environment,\n VariableType,\n FeatureFlagType,\n SDKCoreParameters,\n SDKConfigurationType,\n ExternalPackageInfoType,\n FeatureFlagVariableType,\n TrackConversionParamsType,\n FeatureVariableResultType,\n RemoteVisitorDataParamsType,\n InternalSDKConfigurationType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n Milliseconds,\n} from './types';\nexport { DEFAULT_CLEANUP_INTERVAL } from './kameleoonData';\nexport {\n ApplicationVersion,\n CustomData,\n Conversion,\n Device,\n Cookie,\n Browser,\n UserAgent,\n DeviceType,\n CookieType,\n GeolocationData,\n GeolocationInfoType,\n OperatingSystemType,\n OperatingSystem,\n BrowserType,\n PageView,\n KameleoonData,\n KameleoonDataType,\n PageViewParametersType,\n ConversionParametersType,\n ApplicationVersionDataType,\n} from './kameleoonData';\nexport {\n RealTimeEventType,\n IExternalEventSource,\n EventSourceOpenParametersType,\n IExternalEventSourceConstructor,\n} from './eventSource';\nexport {\n Header,\n HeadersType,\n HttpMethod,\n TrackParametersType,\n IExternalRequestDispatcher,\n} from './requester';\n"],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSONType } from './clientConfiguration';
|
|
2
2
|
import { CustomData, KameleoonDataType } from './kameleoonData';
|
|
3
|
-
import { TrackConversionParamsType, FeatureFlagType, GetFeatureFlagVariableParamsType, FeatureVariableResultType, SDKCoreParameters, RemoteVisitorDataParamsType, GetVisitorWarehouseAudienceParamsType,
|
|
3
|
+
import { TrackConversionParamsType, FeatureFlagType, GetFeatureFlagVariableParamsType, FeatureVariableResultType, SDKCoreParameters, RemoteVisitorDataParamsType, GetVisitorWarehouseAudienceParamsType, SetUserConsentParametersType, FeatureFlagVariableType } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* @interface an interface of KameleoonClient instance
|
|
6
6
|
*/
|
|
@@ -53,13 +53,14 @@ export interface IKameleoonClient {
|
|
|
53
53
|
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
54
54
|
* - `KameleoonException.StorageWrite` Couldn't update storage data
|
|
55
55
|
*/
|
|
56
|
-
trackConversion: ({ visitorCode, goalId, revenue, }: TrackConversionParamsType) => void;
|
|
56
|
+
trackConversion: ({ visitorCode, goalId, revenue, isUniqueIdentifier, }: TrackConversionParamsType) => void;
|
|
57
57
|
/**
|
|
58
58
|
* @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,
|
|
59
59
|
* sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,
|
|
60
60
|
* then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input
|
|
61
61
|
* the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.
|
|
62
62
|
* @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length
|
|
63
|
+
* @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`
|
|
63
64
|
* @returns {void}
|
|
64
65
|
* @throws `KameleoonError` with one of the following `type` s:
|
|
65
66
|
*
|
|
@@ -67,7 +68,7 @@ export interface IKameleoonClient {
|
|
|
67
68
|
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
68
69
|
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
69
70
|
*/
|
|
70
|
-
flush: (visitorCode
|
|
71
|
+
flush: (visitorCode?: string, isUniqueIdentifier?: boolean) => void;
|
|
71
72
|
/**
|
|
72
73
|
* @method getFeatureFlags - returns a list of feature flags stored in the client configuration
|
|
73
74
|
* @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields
|
|
@@ -122,7 +123,7 @@ export interface IKameleoonClient {
|
|
|
122
123
|
/**
|
|
123
124
|
* @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
|
|
124
125
|
* @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.
|
|
125
|
-
* @returns {
|
|
126
|
+
* @returns {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.
|
|
126
127
|
* @throws `KameleoonError` with one of the following `type` s:
|
|
127
128
|
*
|
|
128
129
|
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
@@ -135,12 +136,12 @@ export interface IKameleoonClient {
|
|
|
135
136
|
* - `KameleoonException.JSONParse` - Couldn't parse JSON value
|
|
136
137
|
* - `KameleoonException.NumberParse` - Couldn't parse Number value
|
|
137
138
|
*/
|
|
138
|
-
getFeatureFlagVariable: ({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType) =>
|
|
139
|
+
getFeatureFlagVariable: ({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType) => FeatureFlagVariableType;
|
|
139
140
|
/**
|
|
140
141
|
* @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
|
|
141
142
|
* @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters
|
|
142
143
|
* @param {string} featureKey - a unique key for feature flag
|
|
143
|
-
* @returns {FeatureVariableResultType[]} a list of variable objects containing `type` and `value` fields. You can check the `type` field against `
|
|
144
|
+
* @returns {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.
|
|
144
145
|
* @throws `KameleoonError` with one of the following `type` s:
|
|
145
146
|
*
|
|
146
147
|
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
@@ -187,27 +188,15 @@ export interface IKameleoonClient {
|
|
|
187
188
|
*/
|
|
188
189
|
getEngineTrackingCode: (visitorCode: string) => string;
|
|
189
190
|
/**
|
|
190
|
-
* @method
|
|
191
|
-
* @param {
|
|
192
|
-
* @returns {string} result visitor code
|
|
193
|
-
* @throws `KameleoonError` with one of the following `type` s:
|
|
194
|
-
*
|
|
195
|
-
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
196
|
-
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
197
|
-
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
198
|
-
*/
|
|
199
|
-
getVisitorCode: (params: ServerGetVisitorCodeParametersType | ClientGetVisitorCodeParametersType) => string;
|
|
200
|
-
/**
|
|
201
|
-
* @method setLegalConsent - sets or updates the legal consent status for a visitor identified by their unique visitor code, affecting values in the response cookies based on the consent status
|
|
202
|
-
* @param {ServerSetLegalConsentParametersType | ClientSetLegalConsentParametersType} params - an object of type `ServerSetLegalConsentParametersType` or `ClientSetLegalConsentParametersType`
|
|
191
|
+
* @method setUserConsent - sets or updates the legal consent status for a visitor identified by their unique visitor code, affecting values in the response cookies based on the consent status
|
|
192
|
+
* @param {SetUserConsentParametersType} params - an object of type `SetUserConsentParametersType`, see the type for details.
|
|
203
193
|
* @returns {void}
|
|
204
194
|
* @throws `KameleoonError` with one of the following `type` s:
|
|
205
195
|
*
|
|
206
|
-
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
|
|
207
196
|
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
|
|
208
197
|
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
|
|
209
198
|
*/
|
|
210
|
-
|
|
199
|
+
setUserConsent: (params: SetUserConsentParametersType) => void;
|
|
211
200
|
/**
|
|
212
201
|
* @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.
|
|
213
202
|
* @param {() => void} callback - callback function with no parameters that will be called upon configuration update
|
|
@@ -235,7 +224,7 @@ export declare class KameleoonClient implements IKameleoonClient {
|
|
|
235
224
|
private isOfflineModeOn?;
|
|
236
225
|
private initialized;
|
|
237
226
|
private environment?;
|
|
238
|
-
private
|
|
227
|
+
private visitorCodeManager;
|
|
239
228
|
/**
|
|
240
229
|
* @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core
|
|
241
230
|
*/
|
|
@@ -243,20 +232,19 @@ export declare class KameleoonClient implements IKameleoonClient {
|
|
|
243
232
|
initialize(useCache?: boolean): Promise<boolean>;
|
|
244
233
|
addData(visitorCode: string, ...data: KameleoonDataType[]): void;
|
|
245
234
|
getRemoteVisitorData({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]>;
|
|
246
|
-
trackConversion({ visitorCode, goalId, revenue, }: TrackConversionParamsType): void;
|
|
247
|
-
flush(visitorCode?: string): void;
|
|
235
|
+
trackConversion({ visitorCode, goalId, revenue, isUniqueIdentifier, }: TrackConversionParamsType): void;
|
|
236
|
+
flush(visitorCode?: string, isUniqueIdentifier?: boolean): void;
|
|
248
237
|
getFeatureFlags(): FeatureFlagType[];
|
|
249
238
|
getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[];
|
|
250
239
|
getFeatureFlagVariationKey(visitorCode: string, featureKey: string): string;
|
|
251
|
-
getFeatureFlagVariable({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType):
|
|
240
|
+
getFeatureFlagVariable({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType): FeatureFlagVariableType;
|
|
252
241
|
getFeatureFlagVariables(visitorCode: string, featureKey: string): FeatureVariableResultType[];
|
|
253
242
|
isFeatureFlagActive(visitorCode: string, featureKey: string): boolean;
|
|
254
243
|
getRemoteData(key: string): Promise<JSONType>;
|
|
255
244
|
getVisitorWarehouseAudience({ visitorCode, customDataIndex, warehouseKey, }: GetVisitorWarehouseAudienceParamsType): Promise<CustomData | null>;
|
|
256
245
|
onConfigurationUpdate(callback: () => void): void;
|
|
257
246
|
getEngineTrackingCode(visitorCode: string): string;
|
|
258
|
-
|
|
259
|
-
setLegalConsent(params: ServerSetLegalConsentParametersType | ClientSetLegalConsentParametersType): void;
|
|
247
|
+
setUserConsent({ visitorCode, consent, setData, }: SetUserConsentParametersType): void;
|
|
260
248
|
private _isConsentProvided;
|
|
261
249
|
private _getFeatureFlagVariation;
|
|
262
250
|
}
|