Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kameleoon/javascript-sdk-core

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kameleoon/javascript-sdk-core - npm Package Compare versions

Comparing version 2.5.0 to 2.5.1

9

dist/campaignConfiguration/campaignConfiguration.d.ts

@@ -10,3 +10,3 @@ import { Result } from 'ts-res';

addTargetingData: (visitorCode: string, ...data: KameleoonDataType[]) => Result<void, KameleoonError>;
getUnsentData: (visitorCode: string) => KameleoonDataType[];
getUnsentData: (visitorCode: string) => UnsentTargetingDataType[string] | undefined;
clearUnsentData: (visitorCode: string) => void;

@@ -18,3 +18,3 @@ onConfigurationUpdate: (callback: () => void) => void;

readonly configuration: ConfigurationType;
readonly unsentData: UnsentTargetingDataType;
readonly unsentDataVisitors: string[];
}

@@ -35,9 +35,10 @@ export declare class CampaignConfiguration implements ICampaignConfiguration {

private targetingDataLifetime;
private localCustomDataIndexes;
constructor({ settings, storage, requester, externalClientConfiguration, targetingCleanupInterval, }: CampaignConfigurationParametersType);
initialize(externalEventSource: IExternalEventSourceConstructor, useCache?: boolean): Promise<Result<void, KameleoonError>>;
addTargetingData(visitorCode: string, ...data: KameleoonDataType[]): Result<void, KameleoonError>;
getUnsentData(visitorCode: string): KameleoonDataType[];
getUnsentData(visitorCode: string): UnsentTargetingDataType[string] | undefined;
clearUnsentData(visitorCode: string): void;
onConfigurationUpdate(callback: () => void): void;
get unsentData(): UnsentTargetingDataType;
get unsentDataVisitors(): string[];
get storedTargetingData(): TargetingDataType;

@@ -44,0 +45,0 @@ get experiments(): ExperimentItemType[];

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CampaignConfiguration=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../kameleoonData"),_eventSource=require("../eventSource"),_types=require("../types"),_constants=require("./constants"),_utilities=require("../utilities"),_excluded=["customData"];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 _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}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 _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}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 CampaignConfiguration=/*#__PURE__*/function(){function a(b){var c=b.settings,d=b.storage,e=b.requester,f=b.externalClientConfiguration,g=b.targetingCleanupInterval;if(_classCallCheck(this,a),_defineProperty(this,"configurationUpdateCallback",void 0),_defineProperty(this,"updateConfigurationIntervalId",null),_defineProperty(this,"targetingDataIntervalId",null),_defineProperty(this,"unsentTargetingData",{}),_defineProperty(this,"targetingData",{}),_defineProperty(this,"configurationData",_constants.DEFAULT_CONFIGURATION_DATA),_defineProperty(this,"settings",void 0),_defineProperty(this,"lastUpdate",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"externalClientConfiguration",void 0),_defineProperty(this,"targetingDataLifetime",_constants.CLEANUP_TARGETING_DATA_INTERVAL*_types.Milliseconds.Minute),this.requester=e,this.settings=c,this.lastUpdate=new Date,this.storage=d,this.readStorageData(),this.externalClientConfiguration=f,g){this.targetingDataLifetime=g*_types.Milliseconds.Minute;var h=0>g?1:g;// --- Note ---
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CampaignConfiguration=void 0;var _tsRes=require("ts-res"),_kameleoonData=require("../kameleoonData"),_eventSource=require("../eventSource"),_types=require("../types"),_constants=require("./constants"),_utilities=require("../utilities"),_excluded=["customData"];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 _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}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 _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}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 CampaignConfiguration=/*#__PURE__*/function(){function a(b){var c=b.settings,d=b.storage,e=b.requester,f=b.externalClientConfiguration,g=b.targetingCleanupInterval;if(_classCallCheck(this,a),_defineProperty(this,"configurationUpdateCallback",void 0),_defineProperty(this,"updateConfigurationIntervalId",null),_defineProperty(this,"targetingDataIntervalId",null),_defineProperty(this,"unsentTargetingData",{}),_defineProperty(this,"targetingData",{}),_defineProperty(this,"configurationData",_constants.DEFAULT_CONFIGURATION_DATA),_defineProperty(this,"settings",void 0),_defineProperty(this,"lastUpdate",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"externalClientConfiguration",void 0),_defineProperty(this,"targetingDataLifetime",_constants.CLEANUP_TARGETING_DATA_INTERVAL*_types.Milliseconds.Minute),_defineProperty(this,"localCustomDataIndexes",new Set),this.requester=e,this.settings=c,this.lastUpdate=new Date,this.storage=d,this.readStorageData(),this.externalClientConfiguration=f,g){this.targetingDataLifetime=g*_types.Milliseconds.Minute;var h=0>g?1:g;// --- Note ---
// We can not make delayed code execution recoverable, as it might lead

@@ -7,5 +7,5 @@ // to targeting data storage size overflow

// `targetingData` should not refresh `lastUpdate` time
var f=this.updateStorageData(this.lastUpdate);return f.ok&&d.forEach(function(c){b.unsentTargetingData[a]||(b.unsentTargetingData[a]=[]),b.configuration.customDataLocalOnlyIndexes.length&&_utilities.Utilities.isCustomData(c)&&b.configuration.customDataLocalOnlyIndexes.includes(c.data.index)||b.unsentTargetingData[a].push(c)}),f}},{key:"getUnsentData",value:function getUnsentData(a){var b=this.unsentTargetingData[a];return b?b:[]}},{key:"clearUnsentData",value:function clearUnsentData(a){delete this.unsentTargetingData[a]}},{key:"onConfigurationUpdate",value:function onConfigurationUpdate(a){this.configurationUpdateCallback=a}},{key:"unsentData",get:function get(){return this.unsentTargetingData}},{key:"storedTargetingData",get:function get(){return this.targetingData}},{key:"experiments",get:function get(){return this.configurationData.experiments}},{key:"featureFlags",get:function get(){return this.configurationData.featureFlags}},{key:"configuration",get:function get(){return this.configurationData.configuration}},{key:"checkShouldUpdate",value:function checkShouldUpdate(){var a=this.configurationData,b=a.featureFlags,c=a.experiments,d=a.configuration,e=this.settings.updateInterval;if(!b.length&&!c.length)return!0;if(d.realTimeUpdate)return!0;var f=this.lastUpdate.getTime(),g=Date.now()-e;return f<g}},{key:"cleanupOutdatedTargetingData",value:function cleanupOutdatedTargetingData(){for(var a=Date.now(),b=0,c=Object.entries(this.targetingData);b<c.length;b++){var d=_slicedToArray(c[b],2),e=d[0],f=d[1],g=f.customData,h=_objectWithoutProperties(f,_excluded);if(g)for(var i=0,j=Object.entries(g);i<j.length;i++){var k=_slicedToArray(j[i],2),l=k[0],m=k[1];if(m){var n=m.lastActivityTime+this.targetingDataLifetime<a,o=f[_kameleoonData.KameleoonData.CustomData];n&&o&&delete o[+l],o&&!Object.keys(o).length&&delete f[_kameleoonData.KameleoonData.CustomData]}}for(var p=0,q=Object.entries(h);p<q.length;p++){var r=_slicedToArray(q[p],2),s=r[0],t=r[1],u=t.lastActivityTime+this.targetingDataLifetime<a;u&&delete f[s]}Object.keys(this.targetingData[e]).length||delete this.targetingData[e]}// --- Note ---
var f=this.updateStorageData(this.lastUpdate);return f.ok&&d.forEach(function(c){b.unsentTargetingData[a]||(b.unsentTargetingData[a]=new Map);var d;if(_utilities.Utilities.isCustomData(c)){if(b.localCustomDataIndexes.has(c.data.index))return;d=c.data.index}else d=c.data.type;b.unsentTargetingData[a].set(d,c)}),f}},{key:"getUnsentData",value:function getUnsentData(a){return this.unsentTargetingData[a]}},{key:"clearUnsentData",value:function clearUnsentData(a){delete this.unsentTargetingData[a]}},{key:"onConfigurationUpdate",value:function onConfigurationUpdate(a){this.configurationUpdateCallback=a}},{key:"unsentDataVisitors",get:function get(){return Object.keys(this.unsentTargetingData)}},{key:"storedTargetingData",get:function get(){return this.targetingData}},{key:"experiments",get:function get(){return this.configurationData.experiments}},{key:"featureFlags",get:function get(){return this.configurationData.featureFlags}},{key:"configuration",get:function get(){return this.configurationData.configuration}},{key:"checkShouldUpdate",value:function checkShouldUpdate(){var a=this.configurationData,b=a.featureFlags,c=a.experiments,d=a.configuration,e=this.settings.updateInterval;if(!b.length&&!c.length)return!0;if(d.realTimeUpdate)return!0;var f=this.lastUpdate.getTime(),g=Date.now()-e;return f<g}},{key:"cleanupOutdatedTargetingData",value:function cleanupOutdatedTargetingData(){for(var a=Date.now(),b=0,c=Object.entries(this.targetingData);b<c.length;b++){var d=_slicedToArray(c[b],2),e=d[0],f=d[1],g=f.customData,h=_objectWithoutProperties(f,_excluded);if(g)for(var i=0,j=Object.entries(g);i<j.length;i++){var k=_slicedToArray(j[i],2),l=k[0],m=k[1];if(m){var n=m.lastActivityTime+this.targetingDataLifetime<a,o=f[_kameleoonData.KameleoonData.CustomData];n&&o&&delete o[+l],o&&!Object.keys(o).length&&delete f[_kameleoonData.KameleoonData.CustomData]}}for(var p=0,q=Object.entries(h);p<q.length;p++){var r=_slicedToArray(q[p],2),s=r[0],t=r[1],u=t.lastActivityTime+this.targetingDataLifetime<a;u&&delete f[s]}Object.keys(this.targetingData[e]).length||delete this.targetingData[e]}// --- Note ---
// `targetingData` should not refresh `lastUpdate` time
this.updateStorageData(this.lastUpdate).throw()}},{key:"readStorageData",value:function readStorageData(){var a=this.storage.read();if(a.ok){var b=a.data,c=b.kameleoonTargetingData,d=b.kameleoonConfiguration,e=b.lastUpdate;this.configurationData=d,this.targetingData=c,this.lastUpdate=new Date(Date.parse(e))}}},{key:"updateClientConfiguration",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function a(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=arguments;return _regeneratorRuntime().wrap(function t(a){for(;1;)switch(a.prev=a.next){case 0:if(b=0<s.length&&void 0!==s[0]?s[0]:{},c=b.useCache,d=void 0!==c&&c,e=b.timeStamp,!this.externalClientConfiguration){a.next=6;break}f=this.externalClientConfiguration,g=f.configuration,h=f.experiments,i=f.featureFlagConfigurations,this.configurationData={configuration:g,experiments:h,featureFlags:i},a.next=16;break;case 6:return a.next=8,this.requester.getClientConfiguration(e);case 8:if(j=a.sent,j.ok){a.next=14;break}if(k=this.configurationData,l=k.featureFlags,m=k.experiments,!(d&&l.length&&m.length)){a.next=13;break}return a.abrupt("return",(0,_tsRes.Ok)(!0));case 13:return a.abrupt("return",j);case 14:n=j.data,o=n.configuration,p=n.experiments,q=n.featureFlagConfigurations,this.configurationData={configuration:o,experiments:p,featureFlags:q};case 16:if(r=this.updateStorageData(new Date),r.ok){a.next=19;break}return a.abrupt("return",r);case 19:return a.abrupt("return",(0,_tsRes.Ok)(!0));case 20:case"end":return a.stop();}},a,this)}));return a}()},{key:"updateStorageData",value:function updateStorageData(a){var b={kameleoonTargetingData:this.targetingData,kameleoonConfiguration:this.configurationData,lastUpdate:a.toString()};return this.storage.write(b)}}]),a}();exports.CampaignConfiguration=CampaignConfiguration;
this.updateStorageData(this.lastUpdate).throw()}},{key:"readStorageData",value:function readStorageData(){var a=this.storage.read();if(a.ok){var b=a.data,c=b.kameleoonTargetingData,d=b.kameleoonConfiguration,e=b.lastUpdate;this.configurationData=d,this.targetingData=c,this.lastUpdate=new Date(Date.parse(e))}}},{key:"updateClientConfiguration",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function a(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=arguments;return _regeneratorRuntime().wrap(function t(a){for(;1;)switch(a.prev=a.next){case 0:if(b=0<s.length&&void 0!==s[0]?s[0]:{},c=b.useCache,d=void 0!==c&&c,e=b.timeStamp,!this.externalClientConfiguration){a.next=6;break}f=this.externalClientConfiguration,g=f.configuration,h=f.experiments,i=f.featureFlagConfigurations,this.configurationData={configuration:g,experiments:h,featureFlags:i},a.next=17;break;case 6:return a.next=8,this.requester.getClientConfiguration(e);case 8:if(j=a.sent,j.ok){a.next=14;break}if(k=this.configurationData,l=k.featureFlags,m=k.experiments,!(d&&l.length&&m.length)){a.next=13;break}return a.abrupt("return",(0,_tsRes.Ok)(!0));case 13:return a.abrupt("return",j);case 14:n=j.data,o=n.configuration,p=n.experiments,q=n.featureFlagConfigurations,this.localCustomDataIndexes=new Set(o.customDataLocalOnlyIndexes),this.configurationData={configuration:o,experiments:p,featureFlags:q};case 17:if(r=this.updateStorageData(new Date),r.ok){a.next=20;break}return a.abrupt("return",r);case 20:return a.abrupt("return",(0,_tsRes.Ok)(!0));case 21:case"end":return a.stop();}},a,this)}));return a}()},{key:"updateStorageData",value:function updateStorageData(a){var b={kameleoonTargetingData:this.targetingData,kameleoonConfiguration:this.configurationData,lastUpdate:a.toString()};return this.storage.write(b)}}]),a}();exports.CampaignConfiguration=CampaignConfiguration;
//# sourceMappingURL=campaignConfiguration.js.map
import { ClientSettingsType } from 'src/clientSettings';
import { KameleoonDataType } from 'src/kameleoonData';
import { KameleoonData, KameleoonDataType } from 'src/kameleoonData';
import { Requester, GetClientConfigurationResultType } from 'src/requester';

@@ -127,3 +127,3 @@ import { ClientDataType, IStorage } from 'src/storage';

export type UnsentTargetingDataType = {
[visitorCode: string]: KameleoonDataType[];
[visitorCode: string]: Map<KameleoonData | number, KameleoonDataType> | undefined;
};

@@ -130,0 +130,0 @@ export type CampaignConfigurationParametersType = {

@@ -7,3 +7,3 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _tsRes=require("ts-res"),_cacheManager=require("./cacheManager"),_campaignConfiguration=require("./campaignConfiguration"),_clientSettings=require("./clientSettings"),_constants=require("./constants"),_kameleoonData=require("./kameleoonData"),_kameleoonError=require("./kameleoonError"),_requester=require("./requester"),_storage=require("./storage"),_externalStorage=require("./storage/externalStorage"),_utilities=require("./utilities"),_variationConfiguration=require("./variationConfiguration");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 ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return 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";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}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)}/**

* @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core
*/function a(b){var c=b.siteCode,d=b.configuration,e=b.internalConfiguration;_classCallCheck(this,a),_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"campaignConfiguration",void 0),_defineProperty(this,"variationDataStorage",void 0),_defineProperty(this,"trackingCache",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"externalEventSource",void 0),_defineProperty(this,"externalPackageInfo",void 0);var f=new _clientSettings.ClientSettings(c,d),g=f.settings,h=e.externalStorage,i=e.externalEventSource,j=e.externalPackageInfo,k=e.externalRequestDispatcher,l=e.externalClientConfiguration,m=new _requester.Requester({siteCode:c,environment:g.environment,packageInfo:j,requestDispatcher:k}),n=new _cacheManager.CacheManager(_constants.CACHE_CLEANUP_TIMEOUT),o=new _externalStorage.ExternalStorage(h.initialize(_storage.KameleoonStorageKey.ClientData)),p=new _externalStorage.ExternalStorage(h.initialize(_storage.KameleoonStorageKey.VariationData)),q=new _campaignConfiguration.CampaignConfiguration({settings:g,storage:o,requester:m,externalClientConfiguration:l,targetingCleanupInterval:null===d||void 0===d?void 0:d.targetingDataCleanupInterval});this.requester=m,this.trackingCache=n,this.campaignConfiguration=q,this.variationDataStorage=p,this.externalEventSource=i,this.externalPackageInfo=j}return _createClass(a,[{key:"initialize",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d;return _regeneratorRuntime().wrap(function e(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.campaignConfiguration.initialize(this.externalEventSource,a);case 2:return c=b.sent,c.throw(),d=new _variationConfiguration.VariationConfiguration(this.campaignConfiguration.experiments,this.variationDataStorage),this.variationConfiguration=d,b.abrupt("return",c.ok);case 7:case"end":return b.stop();}},b,this)}));return a}()},{key:"addData",value:function addData(a){var b;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];(b=this.campaignConfiguration).addTargetingData.apply(b,[a].concat(d)).throw()}},{key:"getRemoteVisitorData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j=arguments;return _regeneratorRuntime().wrap(function k(b){for(;1;)switch(b.prev=b.next){case 0:return c=!(1<j.length&&void 0!==j[1])||j[1],b.next=3,this.requester.getVisitorData(a);case 3:if(d=b.sent,e=d.throw(),f=_utilities.Utilities.parseVisitorData(e),c){g=_createForOfIteratorHelper(f);try{for(g.s();!(h=g.n()).done;)i=h.value,this.addData(a,i)}catch(a){g.e(a)}finally{g.f()}}return b.abrupt("return",f);case 8:case"end":return b.stop();}},b,this)}));return a}()},{key:"triggerExperiment",value:function triggerExperiment(a,b){var c=this;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.campaignConfiguration||!this.variationConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var d=this.campaignConfiguration.experiments.find(function(a){return a.id===b+""});if(!d)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.ExperimentConfigurationNotFound,b,a);var e=_utilities.Utilities.getUserAgent(a,this.campaignConfiguration),f=_utilities.Utilities.getDataUrl(a,this.campaignConfiguration),g=this.campaignConfiguration.storedTargetingData[a],h={body:f,visitorCode:a,experimentId:b},i=_constants.UNALLOCATED_VARIATION_ID,j=_utilities.Utilities.checkTargeting({visitorCode:a,experimentId:b,targetingData:g,segment:d.segment,variationConfiguration:this.variationConfiguration,packageInfo:this.externalPackageInfo}).throw();if(i=this.variationConfiguration.getAssociatedVariationId(a,b).else(function(a){if(a.type===_kameleoonError.KameleoonException.NotAllocated)return c.requester.trackExperiment(_objectSpread({isUnallocated:!0,variationId:i,userAgent:e},h)),_constants.UNALLOCATED_VARIATION_ID;throw a}),this.requester.trackExperiment(_objectSpread({variationId:i,isUnallocated:!1,userAgent:e},h)),!j)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NotTargeted,a);return _utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:b,variationId:i}),i}},{key:"trackConversion",value:function trackConversion(a){var b=a.visitorCode,c=a.goalId,d=a.revenue;this.addData(b,new _kameleoonData.Conversion({goalId:c,revenue:d})),this.flushData(b)}},{key:"flushData",value:function flushData(a){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);if("string"==typeof a&&_utilities.Utilities.validateVisitorCode(a).throw(),a)return void _utilities.Utilities.trackData({visitorCode:a,campaignConfiguration:this.campaignConfiguration,requester:this.requester});for(var b in this.campaignConfiguration.unsentData)_utilities.Utilities.trackData({visitorCode:b,campaignConfiguration:this.campaignConfiguration,requester:this.requester})}},{key:"getExperiments",value:function getExperiments(){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.campaignConfiguration.experiments.map(function(a){var b=a.id,c=a.name;return{id:+b,name:c}})}},{key:"getVisitorExperiments",value:function getVisitorExperiments(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];if(!this.variationConfiguration||!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(a).throw();var c,d=this.campaignConfiguration.experiments,e=[],f=this.campaignConfiguration.storedTargetingData[a],g=_createForOfIteratorHelper(d);try{for(g.s();!(c=g.n()).done;){var h=c.value,i=h.id,j=h.name,k=h.segment,l=_utilities.Utilities.checkTargeting({targetingData:f,visitorCode:a,segment:k,variationConfiguration:this.variationConfiguration,experimentId:+i,packageInfo:this.externalPackageInfo}).throw();if(l){// -- If `isActive=false` then return every experiment
*/function a(b){var c=b.siteCode,d=b.configuration,e=b.internalConfiguration;_classCallCheck(this,a),_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"campaignConfiguration",void 0),_defineProperty(this,"variationDataStorage",void 0),_defineProperty(this,"trackingCache",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"externalEventSource",void 0),_defineProperty(this,"externalPackageInfo",void 0);var f=new _clientSettings.ClientSettings(c,d),g=f.settings,h=e.externalStorage,i=e.externalEventSource,j=e.externalPackageInfo,k=e.externalRequestDispatcher,l=e.externalClientConfiguration,m=new _requester.Requester({siteCode:c,environment:g.environment,packageInfo:j,requestDispatcher:k}),n=new _cacheManager.CacheManager(_constants.CACHE_CLEANUP_TIMEOUT),o=new _externalStorage.ExternalStorage(h.initialize(_storage.KameleoonStorageKey.ClientData)),p=new _externalStorage.ExternalStorage(h.initialize(_storage.KameleoonStorageKey.VariationData)),q=new _campaignConfiguration.CampaignConfiguration({settings:g,storage:o,requester:m,externalClientConfiguration:l,targetingCleanupInterval:null===d||void 0===d?void 0:d.targetingDataCleanupInterval});this.requester=m,this.trackingCache=n,this.campaignConfiguration=q,this.variationDataStorage=p,this.externalEventSource=i,this.externalPackageInfo=j}return _createClass(a,[{key:"initialize",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d;return _regeneratorRuntime().wrap(function e(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.campaignConfiguration.initialize(this.externalEventSource,a);case 2:return c=b.sent,c.throw(),d=new _variationConfiguration.VariationConfiguration(this.campaignConfiguration.experiments,this.variationDataStorage),this.variationConfiguration=d,b.abrupt("return",c.ok);case 7:case"end":return b.stop();}},b,this)}));return a}()},{key:"addData",value:function addData(a){var b;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];(b=this.campaignConfiguration).addTargetingData.apply(b,[a].concat(d)).throw()}},{key:"getRemoteVisitorData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j=arguments;return _regeneratorRuntime().wrap(function k(b){for(;1;)switch(b.prev=b.next){case 0:return c=!(1<j.length&&void 0!==j[1])||j[1],b.next=3,this.requester.getVisitorData(a);case 3:if(d=b.sent,e=d.throw(),f=_utilities.Utilities.parseVisitorData(e),c){g=_createForOfIteratorHelper(f);try{for(g.s();!(h=g.n()).done;)i=h.value,this.addData(a,i)}catch(a){g.e(a)}finally{g.f()}}return b.abrupt("return",f);case 8:case"end":return b.stop();}},b,this)}));return a}()},{key:"triggerExperiment",value:function triggerExperiment(a,b){var c=this;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.campaignConfiguration||!this.variationConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var d=this.campaignConfiguration.experiments.find(function(a){return a.id===b+""});if(!d)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.ExperimentConfigurationNotFound,b,a);var e=_utilities.Utilities.getUserAgent(a,this.campaignConfiguration),f=_utilities.Utilities.getDataUrl(a,this.campaignConfiguration),g=this.campaignConfiguration.storedTargetingData[a],h={body:f,visitorCode:a,experimentId:b},i=_constants.UNALLOCATED_VARIATION_ID,j=_utilities.Utilities.checkTargeting({visitorCode:a,experimentId:b,targetingData:g,segment:d.segment,variationConfiguration:this.variationConfiguration,packageInfo:this.externalPackageInfo}).throw();if(i=this.variationConfiguration.getAssociatedVariationId(a,b).else(function(a){if(a.type===_kameleoonError.KameleoonException.NotAllocated)return c.requester.trackExperiment(_objectSpread({isUnallocated:!0,variationId:i,userAgent:e},h)),_constants.UNALLOCATED_VARIATION_ID;throw a}),this.requester.trackExperiment(_objectSpread({variationId:i,isUnallocated:!1,userAgent:e},h)),!j)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NotTargeted,a);return _utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:b,variationId:i}),i}},{key:"trackConversion",value:function trackConversion(a){var b=a.visitorCode,c=a.goalId,d=a.revenue;this.addData(b,new _kameleoonData.Conversion({goalId:c,revenue:d})),this.flushData(b)}},{key:"flushData",value:function flushData(a){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);if("string"==typeof a&&_utilities.Utilities.validateVisitorCode(a).throw(),a)return void _utilities.Utilities.trackData({visitorCode:a,campaignConfiguration:this.campaignConfiguration,requester:this.requester});var b,c=_createForOfIteratorHelper(this.campaignConfiguration.unsentDataVisitors);try{for(c.s();!(b=c.n()).done;){var d=b.value;_utilities.Utilities.trackData({visitorCode:d,campaignConfiguration:this.campaignConfiguration,requester:this.requester})}}catch(a){c.e(a)}finally{c.f()}}},{key:"getExperiments",value:function getExperiments(){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.campaignConfiguration.experiments.map(function(a){var b=a.id,c=a.name;return{id:+b,name:c}})}},{key:"getVisitorExperiments",value:function getVisitorExperiments(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];if(!this.variationConfiguration||!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(a).throw();var c,d=this.campaignConfiguration.experiments,e=[],f=this.campaignConfiguration.storedTargetingData[a],g=_createForOfIteratorHelper(d);try{for(g.s();!(c=g.n()).done;){var h=c.value,i=h.id,j=h.name,k=h.segment,l=_utilities.Utilities.checkTargeting({targetingData:f,visitorCode:a,segment:k,variationConfiguration:this.variationConfiguration,experimentId:+i,packageInfo:this.externalPackageInfo}).throw();if(l){// -- If `isActive=false` then return every experiment
if(!b){e.push({id:+i,name:j});continue}// -- Else first check if there are saved variations for the experiment

@@ -10,0 +10,0 @@ // if there is at least one than it's active

@@ -1,5 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UrlTracking=exports.UrlQuery=exports.UrlParameter=exports.UrlEventType=exports.URL=exports.Header=void 0;var Header=/*#__PURE__*/function(a){return a.UserAgent="User-Agent",a}({});// TODO: important!
// The following code should be put back after test server receive the updated db
// const topLevelDomain = process.env.NODE_ENV === 'test' ? 'net' : 'com';
exports.Header=Header;var topLevelDomain="com",dataTopLevelDomain="io",UrlEventType={CustomData:"eventType=customData",StaticData:"eventType=staticData",Page:"eventType=page",Conversion:"eventType=conversion",Activity:"eventType=activity",Experiment:"eventType=experiment"};exports.UrlEventType=UrlEventType;var UrlParameter={Title:"&title=",ReferrersIndices:"&referrersIndices=",Negative:"&negative=",Revenue:"&revenue=",Overwrite:"&overwrite=",Index:"&index=",BrowserIndex:"&browserIndex=",BrowserVersion:"&browserVersion=",Href:"&href=",DeviceType:"&deviceType=",SiteCode:"&siteCode=",GoalId:"&goalId=",VisitorCode:"&visitorCode=",Environment:"&environment=",VariationId:"&variationId=",Ts:"&ts=",Key:"&key=",SdkName:"&sdkName=",SdkVersion:"&sdkVersion=",ValuesCountMap:"&valuesCountMap=",Nonce:"&nonce=",Id:"&id=",CustomData:"&customData=",CurrentVisit:"&currentVisit=",MaxNumberPreviousVisits:"&maxNumberPreviousVisits="};exports.UrlParameter=UrlParameter;var UrlQuery={Sse:"sse?siteCode=",Mobile:"mobile?siteCode=",Map:"map?siteCode=",Events:"events?siteCode=",Visitor:"visitor?siteCode="};exports.UrlQuery=UrlQuery;var UrlTracking={Visit:"visit/",Map:"map/"};exports.UrlTracking=UrlTracking;var URL_DATA_API="https://data.kameleoon.".concat(dataTopLevelDomain),URL={SERVER_SENT_EVENTS:"https://events.kameleoon.".concat("com",":8110/"),CLIENT_CONFIGURATION:"https://client-config.kameleoon.".concat("com","/"),VISIT_EVENT:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Events),VISIT_DATA:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Visitor),DATA_MAP:"".concat(URL_DATA_API,"/").concat(UrlTracking.Map+UrlQuery.Map)};exports.URL=URL;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UrlTracking=exports.UrlQuery=exports.UrlParameter=exports.UrlEventType=exports.URL=exports.Header=void 0;var Header=/*#__PURE__*/function(a){return a.UserAgent="User-Agent",a}({});exports.Header=Header;var topLevelDomain="com",dataTopLevelDomain="io",UrlEventType={CustomData:"eventType=customData",StaticData:"eventType=staticData",Page:"eventType=page",Conversion:"eventType=conversion",Activity:"eventType=activity",Experiment:"eventType=experiment"};exports.UrlEventType=UrlEventType;var UrlParameter={Title:"&title=",ReferrersIndices:"&referrersIndices=",Negative:"&negative=",Revenue:"&revenue=",Overwrite:"&overwrite=",Index:"&index=",BrowserIndex:"&browserIndex=",BrowserVersion:"&browserVersion=",Href:"&href=",DeviceType:"&deviceType=",SiteCode:"&siteCode=",GoalId:"&goalId=",VisitorCode:"&visitorCode=",Environment:"&environment=",VariationId:"&variationId=",Ts:"&ts=",Key:"&key=",SdkName:"&sdkName=",SdkVersion:"&sdkVersion=",ValuesCountMap:"&valuesCountMap=",Nonce:"&nonce=",Id:"&id=",CustomData:"&customData=",CurrentVisit:"&currentVisit=",MaxNumberPreviousVisits:"&maxNumberPreviousVisits="};exports.UrlParameter=UrlParameter;var UrlQuery={Sse:"sse?siteCode=",Mobile:"mobile?siteCode=",Map:"map?siteCode=",Events:"events?siteCode=",Visitor:"visitor?siteCode="};exports.UrlQuery=UrlQuery;var UrlTracking={Visit:"visit/",Map:"map/"};exports.UrlTracking=UrlTracking;var URL_DATA_API="https://data.kameleoon.".concat(dataTopLevelDomain),URL={SERVER_SENT_EVENTS:"https://events.kameleoon.".concat("com",":8110/"),CLIENT_CONFIGURATION:"https://client-config.kameleoon.".concat("com","/"),VISIT_EVENT:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Events),VISIT_DATA:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Visitor),DATA_MAP:"".concat(URL_DATA_API,"/").concat(UrlTracking.Map+UrlQuery.Map)};exports.URL=URL;
//# sourceMappingURL=constants.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utilities=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),_targeting=require("../targeting"),_kameleoonData=require("../kameleoonData"),_constants=require("../constants"),_constants2=require("./constants");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 ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return 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 _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}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 _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}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 _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}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 _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 _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 Utilities=/*#__PURE__*/function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"checkTargeting",value:function checkTargeting(a){var b=a.segment,c=a.visitorCode,d=a.targetingData,e=a.experimentId,f=a.variationConfiguration,g=a.packageInfo;if(!b||!b.conditionsData.firstLevel.length)return(0,_tsRes.Ok)(!0);if(!f)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));var h={},i=f.getAssignedVariations(c);i.ok&&(h=i.data);var j=new _targeting.TargetingTree(b),k=j.evaluate({variationData:h,sdkInfo:g,targetingData:d,experimentId:e,visitorCode:c});return k}},{key:"validateVisitorCode",value:function validateVisitorCode(a){return 0===a.length?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeEmpty)):a.length>_constants2.VISITOR_CODE_MAX_LENGTH?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeMaxLength)):(0,_tsRes.Ok)()}},{key:"getDataUrl",value:function getDataUrl(a,b){var c=b.getUnsentData(a);return c.map(function(a){return a.url}).join("\n")}},{key:"trackRule",value:function trackRule(a){var b=a.featureFlagVariation,c=a.campaignConfiguration,d=a.visitorCode,e=a.requester,f=a.userAgent,g=b.variationId,h=b.rule,i=this.getDataUrl(d,c),j=h?h.experimentId:0;e.trackExperiment({visitorCode:d,isUnallocated:null===g,body:i,callback:function callback(){c.clearUnsentData(d)},experimentId:j,variationId:g||0,userAgent:f})}},{key:"parseFeatureVariable",value:function parseFeatureVariable(a){var b=a.type,c=a.value;switch(b){case _types.VariableType.BOOLEAN:return(0,_tsRes.Ok)({type:b,value:!!c});case _types.VariableType.STRING:return(0,_tsRes.Ok)({type:b,value:c+""});case _types.VariableType.NUMBER:var d=+c;return Number.isNaN(d)?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NumberParse,c+"")):(0,_tsRes.Ok)({type:b,value:d});case _types.VariableType.JSON:try{var e=JSON.parse(a.value+"");return(0,_tsRes.Ok)({type:b,value:e})}catch(a){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a))}default:(0,_kameleoonError.exhaustCheck)(b);}}},{key:"parseVisitorData",value:function parseVisitorData(a){var b,c=a.currentVisit,d=a.previousVisits;if(c?b=[c]:d&&(b=d),!b)return[];var e=new Map,f=[],g=_toConsumableArray(b[0].customDataEvents);g.sort(function(c,a){return a.time-c.time});var h,i=_createForOfIteratorHelper(g);try{for(i.s();!(h=i.n()).done;){var j=h.value,k=j.data.index;if(!e.has(k)){e.set(k,!0);var l=Object.keys(j.data.valuesCountMap);f.push(_construct(_kameleoonData.CustomData,[k].concat(l)))}}}catch(a){i.e(a)}finally{i.f()}return f}},{key:"parseRegExp",value:function parseRegExp(a){if("/"===a[0]){var b=a.split("/"),c=_slicedToArray(b,3),d=c[0],e=c[1],f=c[2];return new RegExp(e,f)}return new RegExp(a)}},{key:"getUserAgent",value:function getUserAgent(a,b){var c=b.storedTargetingData[a];if(c){var d=c[_kameleoonData.KameleoonData.UserAgent];if(d)return d.value}}},{key:"isCustomData",value:function isCustomData(a){return a.data.type===_kameleoonData.KameleoonData.CustomData}},{key:"updateCache",value:function updateCache(a){var b=a.cacheManager,c=a.visitorCode,d=a.experimentId,e=a.variationId,f=b.getAliveItem(c),g=f?_objectSpread({},f):{};g[d]={variationId:e,expirationTime:Date.now()+_constants.CACHE_ITEM_LIFETIME*_types.Milliseconds.Second},b.add({key:c,data:g,lifetime:_constants.CACHE_ITEM_LIFETIME})}},{key:"getTrackingCode",value:function getTrackingCode(a,b){var c="window.kameleoonQueue=window.kameleoonQueue||[];",d=a.getAliveItem(b);if(!d)return c;var e={};return Object.entries(d).forEach(function(a){var b=_slicedToArray(a,2),d=b[0],f=b[1],g=f.variationId,h=f.expirationTime;h>Date.now()&&(c+="window.kameleoonQueue.push(['Experiments.assignVariation',".concat(d,",").concat(g,"]);"),c+="window.kameleoonQueue.push(['Experiments.trigger',".concat(d,",true]);"),e[+d]={variationId:g,expirationTime:h})}),a.add({key:b,data:e,lifetime:_constants.CACHE_ITEM_LIFETIME}),c}},{key:"trackData",value:function trackData(a){var b=a.visitorCode,c=a.campaignConfiguration,d=a.requester,e=this.getDataUrl(b,c),f=this.getUserAgent(b,c);d.trackData({visitorCode:b,body:e,userAgent:f,callback:function callback(){c.clearUnsentData(b)}})}},{key:"getNonce",value:function getNonce(){for(var a,b=_constants2.HEX_CHARACTERS.length,c="",d=0;d<b;d++)a=Math.floor(Math.random()*b),c+=_constants2.HEX_CHARACTERS.substring(a,a+1);return c}}]),a}();exports.Utilities=Utilities;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utilities=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),_targeting=require("../targeting"),_kameleoonData=require("../kameleoonData"),_constants=require("../constants"),_constants2=require("./constants");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 ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return 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 _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(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 _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 _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 Utilities=/*#__PURE__*/function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"checkTargeting",value:function checkTargeting(a){var b=a.segment,c=a.visitorCode,d=a.targetingData,e=a.experimentId,f=a.variationConfiguration,g=a.packageInfo;if(!b||!b.conditionsData.firstLevel.length)return(0,_tsRes.Ok)(!0);if(!f)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));var h={},i=f.getAssignedVariations(c);i.ok&&(h=i.data);var j=new _targeting.TargetingTree(b),k=j.evaluate({variationData:h,sdkInfo:g,targetingData:d,experimentId:e,visitorCode:c});return k}},{key:"validateVisitorCode",value:function validateVisitorCode(a){return 0===a.length?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeEmpty)):a.length>_constants2.VISITOR_CODE_MAX_LENGTH?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeMaxLength)):(0,_tsRes.Ok)()}},{key:"getDataUrl",value:function getDataUrl(a,b){var c=b.getUnsentData(a),d="";if(!c||!c.size)return d;var e,f=_createForOfIteratorHelper(c.values());try{for(f.s();!(e=f.n()).done;){var g=e.value;d+=g.url+"\n"}}catch(a){f.e(a)}finally{f.f()}return d}},{key:"trackRule",value:function trackRule(a){var b=a.featureFlagVariation,c=a.campaignConfiguration,d=a.visitorCode,e=a.requester,f=a.userAgent,g=b.variationId,h=b.rule,i=this.getDataUrl(d,c),j=h?h.experimentId:0;e.trackExperiment({visitorCode:d,isUnallocated:null===g,body:i,callback:function callback(){c.clearUnsentData(d)},experimentId:j,variationId:g||0,userAgent:f})}},{key:"parseFeatureVariable",value:function parseFeatureVariable(a){var b=a.type,c=a.value;switch(b){case _types.VariableType.BOOLEAN:return(0,_tsRes.Ok)({type:b,value:!!c});case _types.VariableType.STRING:return(0,_tsRes.Ok)({type:b,value:c+""});case _types.VariableType.NUMBER:var d=+c;return Number.isNaN(d)?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NumberParse,c+"")):(0,_tsRes.Ok)({type:b,value:d});case _types.VariableType.JSON:try{var e=JSON.parse(a.value+"");return(0,_tsRes.Ok)({type:b,value:e})}catch(a){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a))}default:(0,_kameleoonError.exhaustCheck)(b);}}},{key:"parseVisitorData",value:function parseVisitorData(a){var b,c=a.currentVisit,d=a.previousVisits;if(c?b=[c]:d&&(b=d),!b)return[];var e=new Map,f=[],g=_toConsumableArray(b[0].customDataEvents);g.sort(function(c,a){return a.time-c.time});var h,i=_createForOfIteratorHelper(g);try{for(i.s();!(h=i.n()).done;){var j=h.value,k=j.data.index;if(!e.has(k)){e.set(k,!0);var l=Object.keys(j.data.valuesCountMap);f.push(_construct(_kameleoonData.CustomData,[k].concat(l)))}}}catch(a){i.e(a)}finally{i.f()}return f}},{key:"parseRegExp",value:function parseRegExp(a){if("/"===a[0]){var b=a.split("/"),c=_slicedToArray(b,3),d=c[0],e=c[1],f=c[2];return new RegExp(e,f)}return new RegExp(a)}},{key:"getUserAgent",value:function getUserAgent(a,b){var c=b.storedTargetingData[a];if(c){var d=c[_kameleoonData.KameleoonData.UserAgent];if(d)return d.value}}},{key:"isCustomData",value:function isCustomData(a){return a.data.type===_kameleoonData.KameleoonData.CustomData}},{key:"updateCache",value:function updateCache(a){var b=a.cacheManager,c=a.visitorCode,d=a.experimentId,e=a.variationId,f=b.getAliveItem(c),g=f?_objectSpread({},f):{};g[d]={variationId:e,expirationTime:Date.now()+_constants.CACHE_ITEM_LIFETIME*_types.Milliseconds.Second},b.add({key:c,data:g,lifetime:_constants.CACHE_ITEM_LIFETIME})}},{key:"getTrackingCode",value:function getTrackingCode(a,b){var c="window.kameleoonQueue=window.kameleoonQueue||[];",d=a.getAliveItem(b);if(!d)return c;var e={};return Object.entries(d).forEach(function(a){var b=_slicedToArray(a,2),d=b[0],f=b[1],g=f.variationId,h=f.expirationTime;h>Date.now()&&(c+="window.kameleoonQueue.push(['Experiments.assignVariation',".concat(d,",").concat(g,"]);"),c+="window.kameleoonQueue.push(['Experiments.trigger',".concat(d,",true]);"),e[+d]={variationId:g,expirationTime:h})}),a.add({key:b,data:e,lifetime:_constants.CACHE_ITEM_LIFETIME}),c}},{key:"trackData",value:function trackData(a){var b=a.visitorCode,c=a.campaignConfiguration,d=a.requester,e=this.getDataUrl(b,c),f=this.getUserAgent(b,c);d.trackData({visitorCode:b,body:e,userAgent:f,callback:function callback(){c.clearUnsentData(b)}})}},{key:"getNonce",value:function getNonce(){for(var a,b=_constants2.HEX_CHARACTERS.length,c="",d=0;d<b;d++)a=Math.floor(Math.random()*b),c+=_constants2.HEX_CHARACTERS.substring(a,a+1);return c}}]),a}();exports.Utilities=Utilities;
//# sourceMappingURL=utilities.js.map
{
"name": "@kameleoon/javascript-sdk-core",
"version": "2.5.0",
"version": "2.5.1",
"description": "Kameleoon JS SDK Core",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc