@kameleoon/javascript-sdk-core 5.12.0 → 5.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 5.12.1 (2025-07-11)
4
+
5
+ ### Patch Changes
6
+
7
+ - Stability and performance improvements
8
+
3
9
  ## 5.12.0 (2025-07-10)
4
10
 
5
11
  ### Features
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientConfiguration=void 0;var _tsRes=require("ts-res"),_types=require("./types"),_eventManager=require("../eventManager"),_constants=require("./constants"),_logging=require("../logging"),_meGroup=require("./meGroup"),_types2=require("../types");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))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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class ClientConfiguration{constructor(a){let{updateInterval:b,urlProvider:c,storage:d,requester:e,dataManager:f,eventSource:g,externalVisitorCodeManager:h,eventManager:i,externalPackageInfo:j,defaultDataFile:k}=a;_defineProperty(this,"updateConfigurationIntervalId",null),_defineProperty(this,"updateType",_types.UpdateType.Polling),_defineProperty(this,"configurationData",_constants.DEFAULT_CLIENT_CONFIGURATION),_defineProperty(this,"featureFlagsData",new Map),_defineProperty(this,"isTargetedDeliveryRule",null),_defineProperty(this,"segmentsData",null),_defineProperty(this,"holdoutData",null),_defineProperty(this,"meGroupsData",new Map),_defineProperty(this,"updateInterval",void 0),_defineProperty(this,"lastUpdate",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"mappedRules",null),_defineProperty(this,"mappedExperiments",null),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"visitorCodeManager",void 0),_defineProperty(this,"eventManager",void 0),_defineProperty(this,"urlProvider",void 0),_defineProperty(this,"lastModified",void 0),_defineProperty(this,"requestTime",void 0),_defineProperty(this,"externalPackageInfo",void 0),_defineProperty(this,"usedDefaultDataFile",!1),_defineProperty(this,"defaultDataFile",void 0),_defineProperty(this,"CACHE_REVALIDATE_PERIOD",6*_types2.Milliseconds.Hour),this.urlProvider=c,this.requester=e,this.updateInterval=b,this.lastUpdate=new Date,this.storage=d,this.dataManager=f,this.eventManager=i,this.visitorCodeManager=h,this.eventSource=g,this.externalPackageInfo=j,this.defaultDataFile=k}async initialize(){_logging.KameleoonLogger.debug("CALL: ClientConfiguration.initialize()"),this.readStorageData();const a=this.checkShouldUpdate();if(a){const a=await this.updateClientConfiguration();if(!a.ok)return _logging.KameleoonLogger.error("Error occurred during client configuration update"),a;const b=a.data;if(b)return _logging.KameleoonLogger.debug("RETURN: ClientConfiguration.initialize()"),(0,_tsRes.Ok)()}return this.updateType!==_types.UpdateType.RealTime||this.eventSource.isOpen?(this.updateType===_types.UpdateType.Polling&&this.handlePollingUpdates(),_logging.KameleoonLogger.debug("RETURN: ClientConfiguration.initialize()"),(0,_tsRes.Ok)()):(this.handleRealTimeUpdates(),_logging.KameleoonLogger.debug("RETURN: ClientConfiguration.initialize()"),(0,_tsRes.Ok)())}cleanupHandlers(){this.eventSource.isOpen&&this.eventSource.close(),this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId)}handleRealTimeUpdates(){this.cleanupHandlers();const a=a=>{this.updateClientConfiguration(a).then(b=>{b.ok&&this.eventManager.fireEvent(_eventManager.EventType.ConfigurationUpdate,{timestamp:a})})};this.eventSource.open(a),this.eventSource.onError(a=>{_logging.KameleoonLogger.error`Error occurred during real-time update: ${a}. Switching to polling updates while the connection is not restored.`,this.updateType=_types.UpdateType.Polling,this.handlePollingUpdates()})}handlePollingUpdates(){this.cleanupHandlers();try{this.updateConfigurationIntervalId=setInterval(this.updateClientConfiguration.bind(this),this.updateInterval)}catch(a){throw this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId),a}}get featureFlags(){return this.featureFlagsData}get configuration(){return this.configurationData.configuration}get segments(){if(this.segmentsData)return this.segmentsData;const a=new Map;return this.featureFlagsData.forEach(b=>{b.rules.forEach(b=>{b.segment&&!a.has(b.segment.id.toString())&&a.set(b.segment.id.toString(),b.segment)})}),this.segmentsData=a,a}get ruleMap(){var a;if(null!==(a=this.mappedRules)&&void 0!==a&&a.size)return this.mappedRules;const b=new Map;for(const a of this.featureFlags.values())for(const c of a.rules){const{id:d,experimentId:e,variationByExposition:f}=c,g=new Map;f.forEach(a=>{let{variationKey:b,variationId:c}=a;"number"==typeof c&&g.set(b,c)}),b.set(d,{featureId:a.id,experimentId:e,variations:g})}return this.mappedRules=b,b}get experimentMap(){var a;if(null!==(a=this.mappedExperiments)&&void 0!==a&&a.size)return this.mappedExperiments;const b=new Map;for(const a of this.featureFlags.values())for(const c of a.rules){const{experimentId:a,variationByExposition:d}=c,e=new Map;d.forEach(a=>{let{variationKey:b,variationId:c}=a;"number"==typeof c&&e.set(b,c)}),b.set(a,{type:c.type,variations:e})}return this.mappedExperiments=b,b}get holdout(){return this.holdoutData}get meGroups(){return this.meGroupsData}get isConsentRequired(){return this.configuration.consentType===_types.ConsentType.Required}get hasAnyTargetedDeliveryRule(){if(null!==this.isTargetedDeliveryRule)return this.isTargetedDeliveryRule;for(const a of this.featureFlags.values())if(a.environmentEnabled&&a.rules.some(a=>a.type===_types.RuleType.TARGETED_DELIVERY))return!0;return!1}checkShouldUpdate(){const{configuration:a}=this.configurationData;if(this.updateType=a.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,!this.featureFlags.size)return!0;const b=this.lastUpdate.getTime(),c=Date.now()-this.updateInterval;return b<c}readStorageData(){_logging.KameleoonLogger.debug("CALL: ClientConfiguration.readStorageData()");const a=this.storage.read();if(a.ok){let{data:e,lastUpdate:f,lastModified:g,requestTime:h}=a.data;if(this.defaultDataFile)try{var b,c,d;const a=JSON.parse(this.defaultDataFile);this.defaultDataFile=void 0,this.usedDefaultDataFile=!0;const f=null!==(b=null!==(c=e.dateModified)&&void 0!==c?c:h)&&void 0!==b?b:-1,g=null!==(d=a.dateModified)&&void 0!==d?d:0;(!h||g>f)&&(e=a)}catch(a){_logging.KameleoonLogger.error`Error parsing default data file: ${a}`}this.updateConfigurationData(e,!1),this.lastUpdate=this.usedDefaultDataFile?new Date(0):new Date(Date.parse(f)),this.lastModified=g,this.requestTime=h}_logging.KameleoonLogger.debug`RETURN: ClientConfiguration.readStorageData() -> (result: ${a.ok})`}async updateClientConfiguration(a){const b=Date.now();if(this.usedDefaultDataFile)return this.updateClientConfigurationInBackground(),(0,_tsRes.Ok)(!1);if(this.requestTime&&!a&&!this.externalPackageInfo.isServer){if(b-this.requestTime<=this.CACHE_REVALIDATE_PERIOD)return this.updateClientConfigurationInBackground(),(0,_tsRes.Ok)(!1);_logging.KameleoonLogger.debug`Cached configuration data has expired. Fetching fresh data.`}const c=await this.requester.getClientConfiguration(a,this.lastModified);return this.applyNewConfigurationDataFromResponse(c)}updateClientConfigurationInBackground(){setTimeout(async()=>{const a=await this.requester.getClientConfiguration(void 0,this.lastModified);await this.applyNewConfigurationDataFromResponse(a)},0)}async applyNewConfigurationDataFromResponse(a){var b,c;if(this.requestTime=Date.now(),!a.ok)return this.featureFlags.size?(_logging.KameleoonLogger.error("Error occurred while updating configuration. Existing configuration will be used as a fallback."),(0,_tsRes.Ok)(!0)):a;if(void 0===a.data.configuration)return this.updateStorageData(),(0,_tsRes.Ok)(!1);const d=a.data.configuration;this.updateConfigurationData(d,!0),this.dataManager.clearTrees(),null===(b=this.mappedRules)||void 0===b?void 0:b.clear(),null===(c=this.experimentMap)||void 0===c?void 0:c.clear(),this.isTargetedDeliveryRule=null,a.data.lastModified&&(this.lastModified=a.data.lastModified);const e=this.updateStorageData();if(!e.ok)return e;const f=d.configuration.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,g=f!==this.updateType;return g&&(this.updateType=f,_logging.KameleoonLogger.info`Configuration update type was toggled to ${_types.UpdateType[f]}`,await this.initialize()),(0,_tsRes.Ok)(g)}updateConfigurationData(a){let b=!(1<arguments.length&&arguments[1]!==void 0)||arguments[1];const{configuration:c,featureFlags:d,customData:e,holdout:f,segments:g,dateModified:h}=a;let i=null,j=null;if(b&&(i=g?new Map(g.map(a=>[a.id.toString(),a])):null,null!==e&&void 0!==e&&e.length)){j=new Map;for(let a of e)if(void 0!==a.id)j.set(a.id,a.index);else{j=null;break}}const k=new Map;for(const c of d)k.set(c.featureKey,c),b&&(this.updateFeatureFlagSegments(c,i),this.updateFeatureFlagBucketingCustomDataId(c,j));this.featureFlagsData=k,null!==e&&void 0!==e&&e.length&&(this.dataManager.customDataIndexes=e),this.meGroupsData=this.makeMEGroups(d),this.holdoutData=null!==f&&void 0!==f?f:null,this.configurationData={configuration:c,customData:e,holdout:f,dateModified:h},this.urlProvider.dataApiDomain=a.configuration.dataApiDomain,this.updateConsentRequired(),this.segmentsData=i}updateFeatureFlagSegments(a,b){null!==b&&a.rules.forEach(a=>{var c;const d=a.segmentId;a.segment=null==d?null:null!==(c=b.get(d.toString()))&&void 0!==c?c:null})}updateFeatureFlagBucketingCustomDataId(a,b){const c=a.bucketingCustomDataId;null!=c&&b&&(a.bucketingCustomDataIndex=b.get(c))}makeMEGroups(a){const b=new Map;a.forEach(a=>{const c=a.mutuallyExclusiveGroup;if(c){let d=b.get(c);d?d.push(a):b.set(c,[a])}});const c=new Map;return b.forEach((a,b)=>{c.set(b,new _meGroup.MEGroup(a))}),c}updateStorageData(){this.lastUpdate=new Date;const a=_objectSpread(_objectSpread({},this.configurationData),{},{featureFlags:Array.from(this.featureFlags.values())}),b={data:a,lastUpdate:this.lastUpdate.toString(),lastModified:this.lastModified,requestTime:this.requestTime};return this.storage.write(b)}updateConsentRequired(){this.visitorCodeManager.consentRequired=this.isConsentRequired&&!this.hasAnyTargetedDeliveryRule}}exports.ClientConfiguration=ClientConfiguration;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientConfiguration=void 0;var _tsRes=require("ts-res"),_types=require("./types"),_eventManager=require("../eventManager"),_constants=require("./constants"),_logging=require("../logging"),_meGroup=require("./meGroup"),_types2=require("../types");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))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||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){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)}class ClientConfiguration{constructor(a){let{updateInterval:b,urlProvider:c,storage:d,requester:e,dataManager:f,eventSource:g,externalVisitorCodeManager:h,eventManager:i,externalPackageInfo:j,defaultDataFile:k}=a;_defineProperty(this,"updateConfigurationIntervalId",null),_defineProperty(this,"updateType",_types.UpdateType.Polling),_defineProperty(this,"configurationData",_constants.DEFAULT_CLIENT_CONFIGURATION),_defineProperty(this,"featureFlagsData",new Map),_defineProperty(this,"isTargetedDeliveryRule",null),_defineProperty(this,"segmentsData",null),_defineProperty(this,"holdoutData",null),_defineProperty(this,"meGroupsData",new Map),_defineProperty(this,"updateInterval",void 0),_defineProperty(this,"lastUpdate",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"mappedRules",null),_defineProperty(this,"mappedExperiments",null),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"visitorCodeManager",void 0),_defineProperty(this,"eventManager",void 0),_defineProperty(this,"urlProvider",void 0),_defineProperty(this,"lastModified",void 0),_defineProperty(this,"requestTime",void 0),_defineProperty(this,"externalPackageInfo",void 0),_defineProperty(this,"usedDefaultDataFile",!1),_defineProperty(this,"defaultDataFile",void 0),_defineProperty(this,"CACHE_REVALIDATE_PERIOD",90*_types2.Milliseconds.Minute),this.urlProvider=c,this.requester=e,this.updateInterval=b,this.lastUpdate=new Date,this.storage=d,this.dataManager=f,this.eventManager=i,this.visitorCodeManager=h,this.eventSource=g,this.externalPackageInfo=j,this.defaultDataFile=k}async initialize(){_logging.KameleoonLogger.debug("CALL: ClientConfiguration.initialize()"),this.readStorageData();const a=this.checkShouldUpdate();if(a){const a=await this.updateClientConfiguration();if(!a.ok)return _logging.KameleoonLogger.error("Error occurred during client configuration update"),a;const b=a.data;if(b)return _logging.KameleoonLogger.debug("RETURN: ClientConfiguration.initialize()"),(0,_tsRes.Ok)()}return this.updateType!==_types.UpdateType.RealTime||this.eventSource.isOpen?(this.updateType===_types.UpdateType.Polling&&this.handlePollingUpdates(),_logging.KameleoonLogger.debug("RETURN: ClientConfiguration.initialize()"),(0,_tsRes.Ok)()):(this.handleRealTimeUpdates(),_logging.KameleoonLogger.debug("RETURN: ClientConfiguration.initialize()"),(0,_tsRes.Ok)())}cleanupHandlers(){this.eventSource.isOpen&&this.eventSource.close(),this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId)}handleRealTimeUpdates(){this.cleanupHandlers();const a=a=>{this.updateClientConfiguration(a).then(b=>{b.ok&&this.eventManager.fireEvent(_eventManager.EventType.ConfigurationUpdate,{timestamp:a})})};this.eventSource.open(a),this.eventSource.onError(a=>{_logging.KameleoonLogger.error`Error occurred during real-time update: ${a}. Switching to polling updates while the connection is not restored.`,this.updateType=_types.UpdateType.Polling,this.handlePollingUpdates()})}handlePollingUpdates(){this.cleanupHandlers();try{this.updateConfigurationIntervalId=setInterval(this.updateClientConfiguration.bind(this),this.updateInterval)}catch(a){throw this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId),a}}get featureFlags(){return this.featureFlagsData}get configuration(){return this.configurationData.configuration}get segments(){if(this.segmentsData)return this.segmentsData;const a=new Map;return this.featureFlagsData.forEach(b=>{b.rules.forEach(b=>{b.segment&&!a.has(b.segment.id.toString())&&a.set(b.segment.id.toString(),b.segment)})}),this.segmentsData=a,a}get ruleMap(){var a;if(null!==(a=this.mappedRules)&&void 0!==a&&a.size)return this.mappedRules;const b=new Map;for(const a of this.featureFlags.values())for(const c of a.rules){const{id:d,experimentId:e,variationByExposition:f}=c,g=new Map;f.forEach(a=>{let{variationKey:b,variationId:c}=a;"number"==typeof c&&g.set(b,c)}),b.set(d,{featureId:a.id,experimentId:e,variations:g})}return this.mappedRules=b,b}get experimentMap(){var a;if(null!==(a=this.mappedExperiments)&&void 0!==a&&a.size)return this.mappedExperiments;const b=new Map;for(const a of this.featureFlags.values())for(const c of a.rules){const{experimentId:a,variationByExposition:d}=c,e=new Map;d.forEach(a=>{let{variationKey:b,variationId:c}=a;"number"==typeof c&&e.set(b,c)}),b.set(a,{type:c.type,variations:e})}return this.mappedExperiments=b,b}get holdout(){return this.holdoutData}get meGroups(){return this.meGroupsData}get isConsentRequired(){return this.configuration.consentType===_types.ConsentType.Required}get hasAnyTargetedDeliveryRule(){if(null!==this.isTargetedDeliveryRule)return this.isTargetedDeliveryRule;for(const a of this.featureFlags.values())if(a.environmentEnabled&&a.rules.some(a=>a.type===_types.RuleType.TARGETED_DELIVERY))return!0;return!1}checkShouldUpdate(){const{configuration:a}=this.configurationData;if(this.updateType=a.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,!this.featureFlags.size)return!0;const b=this.lastUpdate.getTime(),c=Date.now()-this.updateInterval;return b<c}readStorageData(){_logging.KameleoonLogger.debug("CALL: ClientConfiguration.readStorageData()");const a=this.storage.read();if(a.ok){let{data:e,lastUpdate:f,lastModified:g,requestTime:h}=a.data;if(this.defaultDataFile)try{var b,c,d;const a=JSON.parse(this.defaultDataFile);this.defaultDataFile=void 0,this.usedDefaultDataFile=!0;const f=null!==(b=null!==(c=e.dateModified)&&void 0!==c?c:h)&&void 0!==b?b:-1,g=null!==(d=a.dateModified)&&void 0!==d?d:0;(!h||g>f)&&(e=a)}catch(a){_logging.KameleoonLogger.error`Error parsing default data file: ${a}`}this.updateConfigurationData(e,!1),this.lastUpdate=this.usedDefaultDataFile?new Date(0):new Date(Date.parse(f)),this.lastModified=g,this.requestTime=h}_logging.KameleoonLogger.debug`RETURN: ClientConfiguration.readStorageData() -> (result: ${a.ok})`}async updateClientConfiguration(a){const b=Date.now();if(this.usedDefaultDataFile)return this.updateClientConfigurationInBackground(),(0,_tsRes.Ok)(!1);if(this.requestTime&&!a&&!this.externalPackageInfo.isServer){if(b-this.requestTime<=this.CACHE_REVALIDATE_PERIOD)return this.updateClientConfigurationInBackground(),(0,_tsRes.Ok)(!1);_logging.KameleoonLogger.debug`Cached configuration data has expired. Fetching fresh data.`}const c=await this.requester.getClientConfiguration(a,this.lastModified);return this.applyNewConfigurationDataFromResponse(c)}updateClientConfigurationInBackground(){setTimeout(async()=>{const a=await this.requester.getClientConfiguration(void 0,this.lastModified);await this.applyNewConfigurationDataFromResponse(a)},0)}async applyNewConfigurationDataFromResponse(a){var b,c;if(this.requestTime=Date.now(),!a.ok)return this.featureFlags.size?(_logging.KameleoonLogger.error("Error occurred while updating configuration. Existing configuration will be used as a fallback."),(0,_tsRes.Ok)(!0)):a;if(void 0===a.data.configuration)return this.updateStorageData(),(0,_tsRes.Ok)(!1);const d=a.data.configuration;this.updateConfigurationData(d,!0),this.dataManager.clearTrees(),null===(b=this.mappedRules)||void 0===b?void 0:b.clear(),null===(c=this.experimentMap)||void 0===c?void 0:c.clear(),this.isTargetedDeliveryRule=null,a.data.lastModified&&(this.lastModified=a.data.lastModified);const e=this.updateStorageData();if(!e.ok)return e;const f=d.configuration.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,g=f!==this.updateType;return g&&(this.updateType=f,_logging.KameleoonLogger.info`Configuration update type was toggled to ${_types.UpdateType[f]}`,await this.initialize()),(0,_tsRes.Ok)(g)}updateConfigurationData(a){let b=!(1<arguments.length&&arguments[1]!==void 0)||arguments[1];const{configuration:c,featureFlags:d,customData:e,holdout:f,segments:g,dateModified:h}=a;let i=null,j=null;if(b&&(i=g?new Map(g.map(a=>[a.id.toString(),a])):null,null!==e&&void 0!==e&&e.length)){j=new Map;for(let a of e)if(void 0!==a.id)j.set(a.id,a.index);else{j=null;break}}const k=new Map;for(const c of d)k.set(c.featureKey,c),b&&(this.updateFeatureFlagSegments(c,i),this.updateFeatureFlagBucketingCustomDataId(c,j));this.featureFlagsData=k,null!==e&&void 0!==e&&e.length&&(this.dataManager.customDataIndexes=e),this.meGroupsData=this.makeMEGroups(d),this.holdoutData=null!==f&&void 0!==f?f:null,this.configurationData={configuration:c,customData:e,holdout:f,dateModified:h},this.urlProvider.dataApiDomain=a.configuration.dataApiDomain,this.updateConsentRequired(),this.segmentsData=i}updateFeatureFlagSegments(a,b){null!==b&&a.rules.forEach(a=>{var c;const d=a.segmentId;a.segment=null==d?null:null!==(c=b.get(d.toString()))&&void 0!==c?c:null})}updateFeatureFlagBucketingCustomDataId(a,b){const c=a.bucketingCustomDataId;null!=c&&b&&(a.bucketingCustomDataIndex=b.get(c))}makeMEGroups(a){const b=new Map;a.forEach(a=>{const c=a.mutuallyExclusiveGroup;if(c){let d=b.get(c);d?d.push(a):b.set(c,[a])}});const c=new Map;return b.forEach((a,b)=>{c.set(b,new _meGroup.MEGroup(a))}),c}updateStorageData(){this.lastUpdate=new Date;const a=_objectSpread(_objectSpread({},this.configurationData),{},{featureFlags:Array.from(this.featureFlags.values())}),b={data:a,lastUpdate:this.lastUpdate.toString(),lastModified:this.lastModified,requestTime:this.requestTime};return this.storage.write(b)}updateConsentRequired(){this.visitorCodeManager.consentRequired=this.isConsentRequired&&!this.hasAnyTargetedDeliveryRule}}exports.ClientConfiguration=ClientConfiguration;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/javascript-sdk-core",
3
- "version": "5.12.0",
3
+ "version": "5.12.1",
4
4
  "description": "Kameleoon JS SDK Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",