@kameleoon/javascript-sdk-core 4.0.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/clientConfiguration/clientConfiguration.d.ts +5 -2
  3. package/dist/clientConfiguration/clientConfiguration.js +1 -1
  4. package/dist/clientConfiguration/clientConfiguration.js.map +1 -1
  5. package/dist/clientConfiguration/constants.d.ts +3 -2
  6. package/dist/clientConfiguration/constants.js +1 -1
  7. package/dist/clientConfiguration/constants.js.map +1 -1
  8. package/dist/clientConfiguration/index.d.ts +1 -1
  9. package/dist/clientConfiguration/index.js +1 -1
  10. package/dist/clientConfiguration/index.js.map +1 -1
  11. package/dist/clientConfiguration/types.d.ts +1 -0
  12. package/dist/clientConfiguration/types.js.map +1 -1
  13. package/dist/constants.js +1 -1
  14. package/dist/constants.js.map +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/kameleoonClient.d.ts +7 -3
  19. package/dist/kameleoonClient.js +1 -1
  20. package/dist/kameleoonClient.js.map +1 -1
  21. package/dist/kameleoonClientInterface.d.ts +38 -3
  22. package/dist/kameleoonClientInterface.js.map +1 -1
  23. package/dist/kameleoonData/applicationVersion.d.ts +0 -9
  24. package/dist/kameleoonData/applicationVersion.js.map +1 -1
  25. package/dist/kameleoonData/browser.d.ts +3 -12
  26. package/dist/kameleoonData/browser.js +1 -1
  27. package/dist/kameleoonData/browser.js.map +1 -1
  28. package/dist/kameleoonData/conversion.d.ts +11 -13
  29. package/dist/kameleoonData/conversion.js +1 -1
  30. package/dist/kameleoonData/conversion.js.map +1 -1
  31. package/dist/kameleoonData/cookie.d.ts +0 -9
  32. package/dist/kameleoonData/cookie.js.map +1 -1
  33. package/dist/kameleoonData/customData.d.ts +3 -13
  34. package/dist/kameleoonData/customData.js +1 -1
  35. package/dist/kameleoonData/customData.js.map +1 -1
  36. package/dist/kameleoonData/dataManager.d.ts +11 -5
  37. package/dist/kameleoonData/dataManager.js +1 -1
  38. package/dist/kameleoonData/dataManager.js.map +1 -1
  39. package/dist/kameleoonData/dataProcessor.d.ts +13 -6
  40. package/dist/kameleoonData/dataProcessor.js +1 -1
  41. package/dist/kameleoonData/dataProcessor.js.map +1 -1
  42. package/dist/kameleoonData/device.d.ts +3 -12
  43. package/dist/kameleoonData/device.js +1 -1
  44. package/dist/kameleoonData/device.js.map +1 -1
  45. package/dist/kameleoonData/geolocation.d.ts +3 -12
  46. package/dist/kameleoonData/geolocation.js +1 -1
  47. package/dist/kameleoonData/geolocation.js.map +1 -1
  48. package/dist/kameleoonData/index.d.ts +1 -0
  49. package/dist/kameleoonData/index.js +1 -1
  50. package/dist/kameleoonData/index.js.map +1 -1
  51. package/dist/kameleoonData/kameleoonConversionScore.d.ts +15 -0
  52. package/dist/kameleoonData/kameleoonConversionScore.js +2 -0
  53. package/dist/kameleoonData/kameleoonConversionScore.js.map +1 -0
  54. package/dist/kameleoonData/operatingSystem.d.ts +3 -12
  55. package/dist/kameleoonData/operatingSystem.js +1 -1
  56. package/dist/kameleoonData/operatingSystem.js.map +1 -1
  57. package/dist/kameleoonData/pageView.d.ts +4 -13
  58. package/dist/kameleoonData/pageView.js +1 -1
  59. package/dist/kameleoonData/pageView.js.map +1 -1
  60. package/dist/kameleoonData/types.d.ts +54 -11
  61. package/dist/kameleoonData/types.js +1 -1
  62. package/dist/kameleoonData/types.js.map +1 -1
  63. package/dist/kameleoonData/userAgent.d.ts +0 -9
  64. package/dist/kameleoonData/userAgent.js.map +1 -1
  65. package/dist/kameleoonData/visitProcessor.d.ts +34 -0
  66. package/dist/kameleoonData/visitProcessor.js +2 -0
  67. package/dist/kameleoonData/visitProcessor.js.map +1 -0
  68. package/dist/kameleoonData/visitsData.d.ts +7 -21
  69. package/dist/kameleoonData/visitsData.js +1 -1
  70. package/dist/kameleoonData/visitsData.js.map +1 -1
  71. package/dist/requester/constants.js +1 -1
  72. package/dist/requester/constants.js.map +1 -1
  73. package/dist/requester/requester.d.ts +2 -3
  74. package/dist/requester/requester.js +1 -1
  75. package/dist/requester/requester.js.map +1 -1
  76. package/dist/requester/types.d.ts +15 -3
  77. package/dist/requester/types.js +1 -1
  78. package/dist/requester/types.js.map +1 -1
  79. package/dist/requester/urlProvider.d.ts +2 -3
  80. package/dist/requester/urlProvider.js +1 -1
  81. package/dist/requester/urlProvider.js.map +1 -1
  82. package/dist/storage/storage.js +1 -1
  83. package/dist/storage/types.d.ts +1 -1
  84. package/dist/storage/types.js.map +1 -1
  85. package/dist/targeting/conditions/browser.js +1 -1
  86. package/dist/targeting/conditions/browser.js.map +1 -1
  87. package/dist/targeting/conditions/conditionFactory.js +1 -1
  88. package/dist/targeting/conditions/conditionFactory.js.map +1 -1
  89. package/dist/targeting/conditions/conversionLikelihood.d.ts +12 -0
  90. package/dist/targeting/conditions/conversionLikelihood.js +2 -0
  91. package/dist/targeting/conditions/conversionLikelihood.js.map +1 -0
  92. package/dist/targeting/conditions/firstVisit.js +1 -1
  93. package/dist/targeting/conditions/firstVisit.js.map +1 -1
  94. package/dist/targeting/conditions/geolocation.js +1 -1
  95. package/dist/targeting/conditions/geolocation.js.map +1 -1
  96. package/dist/targeting/conditions/index.d.ts +1 -0
  97. package/dist/targeting/conditions/index.js +1 -1
  98. package/dist/targeting/conditions/index.js.map +1 -1
  99. package/dist/targeting/conditions/lastVisit.js +1 -1
  100. package/dist/targeting/conditions/lastVisit.js.map +1 -1
  101. package/dist/targeting/conditions/newVisitor.js +1 -1
  102. package/dist/targeting/conditions/newVisitor.js.map +1 -1
  103. package/dist/targeting/conditions/pageUrl.js.map +1 -1
  104. package/dist/targeting/conditions/previousPage.js +1 -1
  105. package/dist/targeting/conditions/previousPage.js.map +1 -1
  106. package/dist/targeting/conditions/sameDayVisits.js +1 -1
  107. package/dist/targeting/conditions/sameDayVisits.js.map +1 -1
  108. package/dist/targeting/conditions/targetFeatureFlag.js +1 -1
  109. package/dist/targeting/conditions/types.d.ts +3 -0
  110. package/dist/targeting/conditions/types.js.map +1 -1
  111. package/dist/targeting/conditions/visits.js +1 -1
  112. package/dist/targeting/conditions/visits.js.map +1 -1
  113. package/dist/targeting/index.d.ts +2 -2
  114. package/dist/targeting/index.js +1 -1
  115. package/dist/targeting/index.js.map +1 -1
  116. package/dist/targeting/types.d.ts +4 -0
  117. package/dist/targeting/types.js.map +1 -1
  118. package/dist/types.d.ts +26 -2
  119. package/dist/types.js.map +1 -1
  120. package/dist/utilities/types.d.ts +6 -1
  121. package/dist/utilities/types.js.map +1 -1
  122. package/dist/utilities/utilities.d.ts +1 -1
  123. package/dist/utilities/utilities.js +1 -1
  124. package/dist/utilities/utilities.js.map +1 -1
  125. package/dist/variationConfiguration/types.d.ts +1 -1
  126. package/dist/variationConfiguration/types.js.map +1 -1
  127. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.2.0 (2024-05-07)
4
+
5
+ ### Features
6
+
7
+ - New method [`getActiveFeatureFlags`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#getactivefeatureflags) for retrieving feature flags that are active for visitor with detailed variation and variables information.
8
+
9
+ ### Patch Changes
10
+
11
+ - Improved _Previous Page_ condition logic
12
+
13
+ ## 4.1.0 (2024-04-19)
14
+
15
+ ### Features
16
+
17
+ - New [Likelihood to Convert](https://developers.kameleoon.com/feature-management-and-experimentation/using-visit-history-in-feature-flags-and-experiments/#predefined-targeting-conditions) targeting condition.
18
+ - [`getRemoteVisitorData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#getremotevisitordata) method now accepts new boolean parameter `isUniqueIdentifier` to obtain all linked visitors data when working with [Cross-device experimentation](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#cross-device-experimentation)
19
+ - Miscellaneous [Cross-device experimentation](https://developers.kameleoon.com/core-concepts/cross-device-experimentation) improvements
20
+
21
+ ### Patch Changes
22
+
23
+ - Fixed the issue with when `_` variable was transformed to duplicate identifier `a` causing `TypeError`
24
+ - Improved visits data collection logic
25
+ - `Browser` condition could throw an error when the browser version wasn't specified on Kameleoon Platform
26
+ - `Geolocation` condition is now case insensitive
27
+ - SDK Core version is no more sent with tracking
28
+
3
29
  ## 4.0.1 (2024-02-21)
4
30
 
5
31
  ### Patch Changes
@@ -5,7 +5,7 @@ import { ClientConfigurationParametersType, ConfigurationType, FeatureFlagType,
5
5
  interface IClientConfiguration {
6
6
  initialize: (useCache?: boolean) => Promise<Result<void, KameleoonError>>;
7
7
  onConfigurationUpdate: (callback: () => void) => void;
8
- readonly featureFlags: FeatureFlagType[];
8
+ readonly featureFlags: Map<string, FeatureFlagType>;
9
9
  readonly configuration: ConfigurationType;
10
10
  readonly segments: Map<string, SegmentType>;
11
11
  readonly ruleMap: Map<number, MappedRuleType>;
@@ -15,6 +15,9 @@ export declare class ClientConfiguration implements IClientConfiguration {
15
15
  private updateConfigurationIntervalId;
16
16
  private updateType;
17
17
  private configurationData;
18
+ private featureFlagsData;
19
+ private isTargetedDeliveryRule;
20
+ private segmentsData;
18
21
  private settings;
19
22
  private lastUpdate;
20
23
  private storage;
@@ -32,7 +35,7 @@ export declare class ClientConfiguration implements IClientConfiguration {
32
35
  private handleRealTimeUpdates;
33
36
  private handlePollingUpdates;
34
37
  onConfigurationUpdate(callback: () => void): void;
35
- get featureFlags(): FeatureFlagType[];
38
+ get featureFlags(): Map<string, FeatureFlagType>;
36
39
  get configuration(): ConfigurationType;
37
40
  get segments(): Map<string, SegmentType>;
38
41
  get ruleMap(): Map<number, MappedRuleType>;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientConfiguration=void 0;var _tsRes=require("ts-res"),_constants=require("./constants"),_types=require("./types"),_utilities=require("../utilities"),_urlProvider=require("../requester/urlProvider");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||!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{settings:b,storage:c,requester:d,dataManager:e,externalClientConfiguration:f,offlineTrackingStorage:g,eventSource:h,externalVisitorCodeManager:i}=a;_defineProperty(this,"configurationUpdateCallback",void 0),_defineProperty(this,"updateConfigurationIntervalId",null),_defineProperty(this,"updateType",_types.UpdateType.Idle),_defineProperty(this,"configurationData",_constants.DEFAULT_CONFIGURATION_DATA),_defineProperty(this,"settings",void 0),_defineProperty(this,"lastUpdate",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"externalClientConfiguration",void 0),_defineProperty(this,"mappedRules",new Map),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"visitorCodeManager",void 0),this.requester=d,this.settings=b,this.lastUpdate=new Date,this.storage=c,this.dataManager=e,this.externalClientConfiguration=f,this.offlineTrackingStorage=g,this.visitorCodeManager=i,this.eventSource=h}async initialize(){this.readStorageData();const a=!!this.externalClientConfiguration,b=this.checkShouldUpdate(a);if(b){const a=await this.updateClientConfiguration();if(!a.ok)return a;const b=a.data;if(b)return(0,_tsRes.Ok)()}return a?(this.handleExternalUpdates(),(0,_tsRes.Ok)()):this.updateType!==_types.UpdateType.RealTime||this.eventSource.isOpen?(this.updateType===_types.UpdateType.Polling&&this.handlePollingUpdates(),(0,_tsRes.Ok)()):(this.updateType=_types.UpdateType.Idle,this.handleRealTimeUpdates(),(0,_tsRes.Ok)())}cleanupHandlers(){this.eventSource.isOpen&&this.eventSource.close(),this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId)}handleExternalUpdates(){this.cleanupHandlers(),this.configurationData=this.externalClientConfiguration}handleRealTimeUpdates(){this.cleanupHandlers();const a=a=>{this.updateClientConfiguration(a).then(a=>{a.ok&&this.configurationUpdateCallback&&this.configurationUpdateCallback()})};this.eventSource.open(a)}handlePollingUpdates(){this.cleanupHandlers();try{this.updateConfigurationIntervalId=setInterval(this.updateClientConfiguration.bind(this),this.settings.updateInterval)}catch(a){throw this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId),a}}onConfigurationUpdate(a){this.configurationUpdateCallback=a}get featureFlags(){return this.configurationData.featureFlags}get configuration(){return this.configurationData.configuration}get segments(){const a=new Map;return this.featureFlags.forEach(b=>{b.rules.forEach(b=>{b.segment&&!a.has(b.segment.id)&&a.set(b.segment.id,b.segment)})}),a}get ruleMap(){if(this.mappedRules.size)return this.mappedRules;const a=new Map;for(const b of this.featureFlags)for(const c of b.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)}),a.set(d,{featureId:b.id,experimentId:e,variations:g})}return this.mappedRules=a,a}get isConsentRequired(){return this.configuration.consentType===_types.ConsentType.Required}get hasAnyTargetedDeliveryRule(){return this.featureFlags.some(a=>a.environmentEnabled&&a.rules.some(a=>a.type===_types.RuleType.TARGETED_DELIVERY))}checkIntegrity(a){if(!a)return!1;const b=Object.keys(a);if(!b.length)return!1;const c=Object.keys(_constants.DEFAULT_CONFIGURATION_DATA);return b.sort().join()===c.sort().join()}checkShouldUpdate(){let a=!!(0<arguments.length&&void 0!==arguments[0])&&arguments[0];const{featureFlags:b,configuration:c}=this.configurationData,{updateInterval:d}=this.settings;if(a)return this.updateType=_types.UpdateType.Idle,!1;if(this.updateType=c.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,!b.length)return!0;const e=this.lastUpdate.getTime(),f=Date.now()-d;return e<f}readStorageData(){const a=this.storage.read();if(a.ok){const{data:b,lastUpdate:c}=a.data,d=this.checkIntegrity(b);d?(_urlProvider.UrlProvider.setDataApiDomain(b.configuration.dataApiDomain),this.configurationData=b,this.lastUpdate=new Date(Date.parse(c))):(_urlProvider.UrlProvider.setDataApiDomain(_constants.DEFAULT_CONFIGURATION_DATA.configuration.dataApiDomain),this.storage.write({data:_constants.DEFAULT_CONFIGURATION_DATA,lastUpdate:this.lastUpdate.toString()}),this.configurationData=_constants.DEFAULT_CONFIGURATION_DATA)}}async updateClientConfiguration(a){const b=await this.requester.getClientConfiguration(a);if(!b.ok){const{featureFlags:a}=this.configurationData;return a.length?(0,_tsRes.Ok)(!0):b}_utilities.Utilities.sendOfflineTracking({storage:this.offlineTrackingStorage,requester:this.requester});const{configuration:c,customData:d}=b.data;this.configurationData=b.data,null!==d&&void 0!==d&&d.length&&(this.dataManager.customDataIndexes=d),this.dataManager.clearTrees(),this.mappedRules.clear();const e=this.updateStorageData();if(!e.ok)return e;const f=c.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,g=f!==this.updateType;g&&(this.updateType=f,await this.initialize());const h=this.isConsentRequired&&!this.hasAnyTargetedDeliveryRule;return this.visitorCodeManager.consentRequired=h,(0,_tsRes.Ok)(g)}updateStorageData(){this.lastUpdate=new Date;const a={data:this.configurationData,lastUpdate:this.lastUpdate.toString()};return _urlProvider.UrlProvider.setDataApiDomain(this.configurationData.configuration.dataApiDomain),this.storage.write(a)}}exports.ClientConfiguration=ClientConfiguration;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientConfiguration=void 0;var _tsRes=require("ts-res"),_constants=require("./constants"),_types=require("./types"),_utilities=require("../utilities"),_urlProvider=require("../requester/urlProvider");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 _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{settings:b,storage:c,requester:d,dataManager:e,externalClientConfiguration:f,offlineTrackingStorage:g,eventSource:h,externalVisitorCodeManager:i}=a;_defineProperty(this,"configurationUpdateCallback",void 0),_defineProperty(this,"updateConfigurationIntervalId",null),_defineProperty(this,"updateType",_types.UpdateType.Idle),_defineProperty(this,"configurationData",_constants.DEFAULT_CONFIGURATION_DATA),_defineProperty(this,"featureFlagsData",new Map),_defineProperty(this,"isTargetedDeliveryRule",null),_defineProperty(this,"segmentsData",null),_defineProperty(this,"settings",void 0),_defineProperty(this,"lastUpdate",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"externalClientConfiguration",void 0),_defineProperty(this,"mappedRules",null),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"visitorCodeManager",void 0),this.requester=d,this.settings=b,this.lastUpdate=new Date,this.storage=c,this.dataManager=e,this.externalClientConfiguration=f,this.offlineTrackingStorage=g,this.visitorCodeManager=i,this.eventSource=h}async initialize(){this.readStorageData();const a=!!this.externalClientConfiguration,b=this.checkShouldUpdate(a);if(b){const a=await this.updateClientConfiguration();if(!a.ok)return a;const b=a.data;if(b)return(0,_tsRes.Ok)()}return a?(this.handleExternalUpdates(),(0,_tsRes.Ok)()):this.updateType!==_types.UpdateType.RealTime||this.eventSource.isOpen?(this.updateType===_types.UpdateType.Polling&&this.handlePollingUpdates(),(0,_tsRes.Ok)()):(this.updateType=_types.UpdateType.Idle,this.handleRealTimeUpdates(),(0,_tsRes.Ok)())}cleanupHandlers(){this.eventSource.isOpen&&this.eventSource.close(),this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId)}handleExternalUpdates(){this.cleanupHandlers();const{customData:a,configuration:b}=this.externalClientConfiguration;this.configurationData={customData:a,configuration:b};for(const a of this.featureFlags.values())this.featureFlagsData.set(a.featureKey,a)}handleRealTimeUpdates(){this.cleanupHandlers();const a=a=>{this.updateClientConfiguration(a).then(a=>{a.ok&&this.configurationUpdateCallback&&this.configurationUpdateCallback()})};this.eventSource.open(a)}handlePollingUpdates(){this.cleanupHandlers();try{this.updateConfigurationIntervalId=setInterval(this.updateClientConfiguration.bind(this),this.settings.updateInterval)}catch(a){throw this.updateConfigurationIntervalId&&clearInterval(this.updateConfigurationIntervalId),a}}onConfigurationUpdate(a){this.configurationUpdateCallback=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)&&a.set(b.segment.id,b.segment)})}),this.segmentsData=a,a}get ruleMap(){if(this.mappedRules)return this.mappedRules;const a=new Map;for(const b of this.featureFlags.values())for(const c of b.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)}),a.set(d,{featureId:b.id,experimentId:e,variations:g})}return this.mappedRules=a,a}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}checkIntegrity(a){if(!a)return!1;const b=Object.keys(a);if(!b.length)return!1;const c=Object.keys(_constants.DEFAULT_CLIENT_CONFIGURATION);return b.sort().join()===c.sort().join()}checkShouldUpdate(){let a=!!(0<arguments.length&&void 0!==arguments[0])&&arguments[0];const{configuration:b}=this.configurationData,{updateInterval:c}=this.settings;if(a)return this.updateType=_types.UpdateType.Idle,!1;if(this.updateType=b.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,!this.featureFlags.size)return!0;const d=this.lastUpdate.getTime(),e=Date.now()-c;return d<e}readStorageData(){const a=this.storage.read();if(a.ok){const{data:b,lastUpdate:c}=a.data,d=this.checkIntegrity(b);if(!d){_urlProvider.UrlProvider.setDataApiDomain(_constants.DEFAULT_CONFIGURATION_DATA.configuration.dataApiDomain);const a=_objectSpread(_objectSpread({},_constants.DEFAULT_CONFIGURATION_DATA),{},{featureFlags:[]});this.storage.write({data:a,lastUpdate:this.lastUpdate.toString()}),this.configurationData=_constants.DEFAULT_CONFIGURATION_DATA}else _urlProvider.UrlProvider.setDataApiDomain(b.configuration.dataApiDomain),this.configurationData=b,this.lastUpdate=new Date(Date.parse(c))}}async updateClientConfiguration(a){var b;const c=await this.requester.getClientConfiguration(a);if(!c.ok)return this.featureFlags.size?(0,_tsRes.Ok)(!0):c;_utilities.Utilities.sendOfflineTracking({storage:this.offlineTrackingStorage,requester:this.requester});const{configuration:d,customData:e,featureFlags:f}=c.data;this.configurationData={configuration:d,customData:e};for(const b of f)this.featureFlagsData.set(b.featureKey,b);null!==e&&void 0!==e&&e.length&&(this.dataManager.customDataIndexes=e),this.dataManager.clearTrees(),null===(b=this.mappedRules)||void 0===b?void 0:b.clear(),this.isTargetedDeliveryRule=null,this.segmentsData=null;const g=this.updateStorageData();if(!g.ok)return g;const h=d.realTimeUpdate?_types.UpdateType.RealTime:_types.UpdateType.Polling,i=h!==this.updateType;i&&(this.updateType=h,await this.initialize());const j=this.isConsentRequired&&!this.hasAnyTargetedDeliveryRule;return this.visitorCodeManager.consentRequired=j,(0,_tsRes.Ok)(i)}updateStorageData(){this.lastUpdate=new Date;const a=_objectSpread(_objectSpread({},this.configurationData),{},{featureFlags:Array.from(this.featureFlags.values())}),b={data:a,lastUpdate:this.lastUpdate.toString()};return _urlProvider.UrlProvider.setDataApiDomain(this.configurationData.configuration.dataApiDomain),this.storage.write(b)}}exports.ClientConfiguration=ClientConfiguration;
2
2
  //# sourceMappingURL=clientConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientConfiguration.js","names":["ClientConfiguration","constructor","a","settings","storage","requester","dataManager","externalClientConfiguration","offlineTrackingStorage","eventSource","externalVisitorCodeManager","_defineProperty","UpdateType","Idle","DEFAULT_CONFIGURATION_DATA","Map","lastUpdate","Date","visitorCodeManager","initialize","readStorageData","isExternalConfiguration","shouldUpdate","checkShouldUpdate","updateResult","updateClientConfiguration","ok","isUpdateTypeToggled","data","Ok","handleExternalUpdates","updateType","RealTime","isOpen","Polling","handlePollingUpdates","handleRealTimeUpdates","cleanupHandlers","close","updateConfigurationIntervalId","clearInterval","configurationData","updateEventCallback","timestamp","then","configurationUpdateCallback","open","setInterval","bind","updateInterval","err","onConfigurationUpdate","callback","featureFlags","configuration","segments","forEach","flag","rules","rule","segment","has","id","set","ruleMap","mappedRules","size","featureFlag","experimentId","variationByExposition","variationMap","variationKey","variationId","featureId","variations","isConsentRequired","consentType","ConsentType","Required","hasAnyTargetedDeliveryRule","some","environmentEnabled","type","RuleType","TARGETED_DELIVERY","checkIntegrity","fields","Object","keys","length","requiredFields","sort","join","skipChecks","arguments","realTimeUpdate","lastUpdateTime","getTime","updateWindowEdge","now","result","read","isStorageValid","UrlProvider","setDataApiDomain","dataApiDomain","parse","write","toString","clientConfigurationResult","getClientConfiguration","Utilities","sendOfflineTracking","customData","customDataIndexes","clearTrees","clear","updateStorageData","toggleUpdateType","consentRequired","exports"],"sources":["../../src/clientConfiguration/clientConfiguration.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError/kameleoonError';\nimport { ClientSettingsType } from 'src/clientSettings/types';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { SegmentType } from 'src/targeting';\nimport { ClientDataType } from 'src/storage';\nimport { IEventSource } from 'src/eventSource';\nimport { DEFAULT_CONFIGURATION_DATA } from './constants';\nimport {\n ClientConfigurationParametersType,\n ConfigurationDataType,\n ConfigurationType,\n ConsentType,\n FeatureFlagType,\n MappedRuleType,\n RuleType,\n UpdateType,\n} from './types';\nimport { Utilities } from 'src/utilities';\nimport { IStorage, OfflineTracking } from 'src/storage/types';\nimport { IVisitorCodeManager } from 'src/visitorCodeManager';\nimport { UrlProvider } from 'src/requester/urlProvider';\n\ninterface IClientConfiguration {\n initialize: (useCache?: boolean) => Promise<Result<void, KameleoonError>>;\n onConfigurationUpdate: (callback: () => void) => void;\n readonly featureFlags: FeatureFlagType[];\n readonly configuration: ConfigurationType;\n readonly segments: Map<string, SegmentType>;\n readonly ruleMap: Map<number, MappedRuleType>;\n}\n\nexport class ClientConfiguration implements IClientConfiguration {\n private configurationUpdateCallback?: () => void;\n private updateConfigurationIntervalId: NodeJS.Timer | null = null;\n private updateType: UpdateType = UpdateType.Idle;\n private configurationData: ConfigurationDataType = DEFAULT_CONFIGURATION_DATA;\n private settings: ClientSettingsType;\n private lastUpdate: Date;\n private storage: IStorage<ClientDataType>;\n private offlineTrackingStorage: IStorage<OfflineTracking>;\n private requester: Requester;\n private eventSource: IEventSource;\n private externalClientConfiguration?: ConfigurationDataType;\n private mappedRules: Map<number, MappedRuleType> = new Map();\n private dataManager: DataManager;\n private visitorCodeManager: IVisitorCodeManager;\n\n constructor({\n settings,\n storage,\n requester,\n dataManager,\n externalClientConfiguration,\n offlineTrackingStorage,\n eventSource,\n externalVisitorCodeManager,\n }: ClientConfigurationParametersType) {\n this.requester = requester;\n this.settings = settings;\n this.lastUpdate = new Date();\n this.storage = storage;\n this.dataManager = dataManager;\n this.externalClientConfiguration = externalClientConfiguration;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.visitorCodeManager = externalVisitorCodeManager;\n this.eventSource = eventSource;\n }\n\n public async initialize(): Promise<Result<void, KameleoonError>> {\n this.readStorageData();\n\n const isExternalConfiguration = Boolean(this.externalClientConfiguration);\n const shouldUpdate = this.checkShouldUpdate(isExternalConfiguration);\n\n if (shouldUpdate) {\n const updateResult = await this.updateClientConfiguration();\n\n if (!updateResult.ok) {\n return updateResult;\n }\n\n // --- Note ---\n // If update type is being toggled `initialize` will be called again\n // so we don't need to continue execution here\n const isUpdateTypeToggled = updateResult.data;\n\n if (isUpdateTypeToggled) {\n return Ok();\n }\n }\n\n if (isExternalConfiguration) {\n this.handleExternalUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.RealTime && !this.eventSource.isOpen) {\n this.updateType = UpdateType.Idle;\n this.handleRealTimeUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.Polling) {\n this.handlePollingUpdates();\n }\n\n return Ok();\n }\n\n private cleanupHandlers(): void {\n if (this.eventSource.isOpen) {\n this.eventSource.close();\n }\n\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n }\n\n private handleExternalUpdates(): void {\n this.cleanupHandlers();\n\n this.configurationData = this.externalClientConfiguration!;\n }\n\n private handleRealTimeUpdates(): void {\n this.cleanupHandlers();\n\n const updateEventCallback = (timestamp: number) => {\n this.updateClientConfiguration(timestamp).then((updateResult) => {\n if (updateResult.ok && this.configurationUpdateCallback) {\n this.configurationUpdateCallback();\n }\n });\n };\n\n this.eventSource.open(updateEventCallback);\n }\n\n private handlePollingUpdates(): void {\n // --- Note ---\n // If `initialize` is called again the interval will be cleared\n // so theoretically we will constantly defer config update\n // but `this.lastUpdate` with `checkShouldUpdate` will prevent that\n this.cleanupHandlers();\n\n // --- Note ---\n // Error Handling is for `setInterval` emergency cleanup\n try {\n this.updateConfigurationIntervalId = setInterval(\n this.updateClientConfiguration.bind(this),\n this.settings.updateInterval,\n );\n } catch (err) {\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n\n throw err;\n }\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n this.configurationUpdateCallback = callback;\n }\n\n get featureFlags(): FeatureFlagType[] {\n return this.configurationData.featureFlags;\n }\n\n get configuration(): ConfigurationType {\n return this.configurationData.configuration;\n }\n\n get segments(): Map<string, SegmentType> {\n const segments = new Map();\n\n this.featureFlags.forEach((flag) => {\n flag.rules.forEach((rule) => {\n if (rule.segment && !segments.has(rule.segment.id)) {\n segments.set(rule.segment.id, rule.segment);\n }\n });\n });\n\n return segments;\n }\n\n get ruleMap(): Map<number, MappedRuleType> {\n if (this.mappedRules.size) {\n return this.mappedRules;\n }\n\n const mappedRules = new Map<number, MappedRuleType>();\n\n for (const featureFlag of this.featureFlags) {\n for (const rule of featureFlag.rules) {\n const { id, experimentId, variationByExposition } = rule;\n const variationMap = new Map<string, number>();\n\n variationByExposition.forEach(({ variationKey, variationId }) => {\n if (typeof variationId === 'number') {\n variationMap.set(variationKey, variationId);\n }\n });\n\n mappedRules.set(id, {\n featureId: featureFlag.id,\n experimentId,\n variations: variationMap,\n });\n }\n }\n\n this.mappedRules = mappedRules;\n\n return mappedRules;\n }\n\n get isConsentRequired(): boolean {\n return this.configuration.consentType === ConsentType.Required;\n }\n\n get hasAnyTargetedDeliveryRule(): boolean {\n return this.featureFlags.some(\n (featureFlag) =>\n featureFlag.environmentEnabled &&\n featureFlag.rules.some(\n (rule) => rule.type === RuleType.TARGETED_DELIVERY,\n ),\n );\n }\n\n // --- Note ---\n // Integrity check covers most of the migration scenarios\n // however in the future it will be changed to a dedicate migration\n // block that can handle all versions migrations\n private checkIntegrity(data: ConfigurationDataType | undefined): boolean {\n if (!data) {\n return false;\n }\n\n const fields = Object.keys(data);\n\n if (!fields.length) {\n return false;\n }\n\n const requiredFields = Object.keys(DEFAULT_CONFIGURATION_DATA);\n\n return fields.sort().join() === requiredFields.sort().join();\n }\n\n private checkShouldUpdate(skipChecks = false): boolean {\n const { featureFlags, configuration } = this.configurationData;\n const { updateInterval } = this.settings;\n\n // --- Note ---\n // Following `updateType` logic is done for client side\n // edge cases where we have previous campaigns on storage already, but we still want\n // to initialize SSE/Polling after page reload\n if (skipChecks) {\n this.updateType = UpdateType.Idle;\n\n return false;\n }\n\n this.updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n if (!featureFlags.length) {\n return true;\n }\n\n const lastUpdateTime = this.lastUpdate.getTime();\n const updateWindowEdge = Date.now() - updateInterval;\n\n return lastUpdateTime < updateWindowEdge;\n }\n\n private readStorageData(): void {\n const result = this.storage.read();\n\n if (result.ok) {\n const { data, lastUpdate } = result.data;\n\n const isStorageValid = this.checkIntegrity(data);\n\n // --- Note ---\n // Cleaning up storage if it's not valid for migration purposes\n if (!isStorageValid) {\n UrlProvider.setDataApiDomain(\n DEFAULT_CONFIGURATION_DATA.configuration.dataApiDomain,\n );\n\n this.storage.write({\n data: DEFAULT_CONFIGURATION_DATA,\n lastUpdate: this.lastUpdate.toString(),\n });\n\n this.configurationData = DEFAULT_CONFIGURATION_DATA;\n } else {\n UrlProvider.setDataApiDomain(data.configuration.dataApiDomain);\n\n this.configurationData = data;\n this.lastUpdate = new Date(Date.parse(lastUpdate));\n }\n }\n }\n\n /**\n * Updates client configuration\n *\n * @param timeStamp - timestamp for real-time configuration update\n *\n * @returns `true` if current update type should be toggled (SSE/Polling)\n */\n private async updateClientConfiguration(\n timestamp?: number,\n ): Promise<Result<boolean, KameleoonError>> {\n const clientConfigurationResult =\n await this.requester.getClientConfiguration(timestamp);\n\n if (!clientConfigurationResult.ok) {\n const { featureFlags } = this.configurationData;\n\n if (featureFlags.length) {\n // TODO: the case of silent fail should be logged when logging is implemented\n return Ok(true);\n }\n\n return clientConfigurationResult;\n }\n\n Utilities.sendOfflineTracking({\n storage: this.offlineTrackingStorage,\n requester: this.requester,\n });\n\n const { configuration, customData } = clientConfigurationResult.data;\n\n this.configurationData = clientConfigurationResult.data;\n\n if (customData?.length) {\n this.dataManager.customDataIndexes = customData;\n }\n\n this.dataManager.clearTrees();\n this.mappedRules.clear();\n\n const result = this.updateStorageData();\n\n if (!result.ok) {\n return result;\n }\n\n const updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n const toggleUpdateType = updateType !== this.updateType;\n\n if (toggleUpdateType) {\n this.updateType = updateType;\n await this.initialize();\n }\n\n // --- Note ---\n // Regarding GDPR policy we should set visitorCode if legal consent isn't required\n // or we have at least one Targeted Delivery rule in configuration\n const consentRequired =\n this.isConsentRequired && !this.hasAnyTargetedDeliveryRule;\n this.visitorCodeManager.consentRequired = consentRequired;\n\n return Ok(toggleUpdateType);\n }\n\n private updateStorageData(): Result<void, KameleoonError> {\n this.lastUpdate = new Date();\n\n const data: ClientDataType = {\n data: this.configurationData,\n lastUpdate: this.lastUpdate.toString(),\n };\n\n UrlProvider.setDataApiDomain(\n this.configurationData.configuration.dataApiDomain,\n );\n\n return this.storage.write(data);\n }\n}\n"],"mappings":"uxBAiCO,KAAM,CAAAA,mBAAoD,CAgB/DC,WAAWA,CAAAC,CAAA,CAS2B,IAT1B,CACVC,QAAQ,CAARA,CAAQ,CACRC,OAAO,CAAPA,CAAO,CACPC,SAAS,CAATA,CAAS,CACTC,WAAW,CAAXA,CAAW,CACXC,2BAA2B,CAA3BA,CAA2B,CAC3BC,sBAAsB,CAAtBA,CAAsB,CACtBC,WAAW,CAAXA,CAAW,CACXC,0BAA0B,CAA1BA,CACiC,CAAC,CAAAR,CAAA,CAAAS,eAAA,4CAAAA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M,CACd,KAEK,CAAArE,CAAU,CAAGuB,CAAa,CAACyC,cAAc,CAC3CnF,iBAAU,CAACoB,QAAQ,CACnBpB,iBAAU,CAACsB,OAAO,CAEhBoF,CAAgB,CAAGvF,CAAU,GAAK,IAAI,CAACA,UAAU,CAEnDuF,CAAgB,GAClB,IAAI,CAACvF,UAAU,CAAGA,CAAU,CAC5B,KAAM,KAAI,CAACZ,UAAU,CAAC,CAAC,EAMzB,KAAM,CAAAoG,CAAe,CACnB,IAAI,CAAC5C,iBAAiB,EAAI,CAAC,IAAI,CAACI,0BAA0B,CAG5D,MAFA,KAAI,CAAC7D,kBAAkB,CAACqG,eAAe,CAAGA,CAAe,CAElD,GAAA1F,SAAE,EAACyF,CAAgB,CAC5B,CAEQD,iBAAiBA,CAAA,CAAiC,CACxD,IAAI,CAACrG,UAAU,CAAG,GAAI,CAAAC,IAAM,CAE5B,KAAM,CAAAW,CAAoB,CAAG,CAC3BA,IAAI,CAAE,IAAI,CAACa,iBAAiB,CAC5BzB,UAAU,CAAE,IAAI,CAACA,UAAU,CAAC4F,QAAQ,CAAC,CACvC,CAAC,CAMD,MAJA,CAAAL,wBAAW,CAACC,gBAAgB,CAC1B,IAAI,CAAC/D,iBAAiB,CAACa,aAAa,CAACmD,aACvC,CAAC,CAEM,IAAI,CAACrG,OAAO,CAACuG,KAAK,CAAC/E,CAAI,CAChC,CACF,CAAC4F,OAAA,CAAAxH,mBAAA,CAAAA,mBAAA"}
1
+ {"version":3,"file":"clientConfiguration.js","names":["ClientConfiguration","constructor","a","settings","storage","requester","dataManager","externalClientConfiguration","offlineTrackingStorage","eventSource","externalVisitorCodeManager","_defineProperty","UpdateType","Idle","DEFAULT_CONFIGURATION_DATA","Map","lastUpdate","Date","visitorCodeManager","initialize","readStorageData","isExternalConfiguration","shouldUpdate","checkShouldUpdate","updateResult","updateClientConfiguration","ok","isUpdateTypeToggled","data","Ok","handleExternalUpdates","updateType","RealTime","isOpen","Polling","handlePollingUpdates","handleRealTimeUpdates","cleanupHandlers","close","updateConfigurationIntervalId","clearInterval","customData","configuration","configurationData","featureFlag","featureFlags","values","featureFlagsData","set","featureKey","updateEventCallback","timestamp","then","configurationUpdateCallback","open","setInterval","bind","updateInterval","err","onConfigurationUpdate","callback","segments","segmentsData","forEach","flag","rules","rule","segment","has","id","ruleMap","mappedRules","experimentId","variationByExposition","variationMap","variationKey","variationId","featureId","variations","isConsentRequired","consentType","ConsentType","Required","hasAnyTargetedDeliveryRule","isTargetedDeliveryRule","environmentEnabled","some","type","RuleType","TARGETED_DELIVERY","checkIntegrity","fields","Object","keys","length","requiredFields","DEFAULT_CLIENT_CONFIGURATION","sort","join","skipChecks","arguments","realTimeUpdate","size","lastUpdateTime","getTime","updateWindowEdge","now","result","read","isStorageValid","UrlProvider","setDataApiDomain","dataApiDomain","_objectSpread","write","toString","parse","b","clientConfigurationResult","getClientConfiguration","Utilities","sendOfflineTracking","customDataIndexes","clearTrees","clear","updateStorageData","toggleUpdateType","consentRequired","Array","from","exports"],"sources":["../../src/clientConfiguration/clientConfiguration.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonError } from 'src/kameleoonError/kameleoonError';\nimport { ClientSettingsType } from 'src/clientSettings/types';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { SegmentType } from 'src/targeting';\nimport { ClientDataType } from 'src/storage';\nimport { IEventSource } from 'src/eventSource';\nimport {\n DEFAULT_CLIENT_CONFIGURATION,\n DEFAULT_CONFIGURATION_DATA,\n} from './constants';\nimport {\n ClientConfigurationDataType,\n ClientConfigurationParametersType,\n ConfigurationDataType,\n ConfigurationType,\n ConsentType,\n FeatureFlagType,\n MappedRuleType,\n RuleType,\n UpdateType,\n} from './types';\nimport { Utilities } from 'src/utilities';\nimport { IStorage, OfflineTracking } from 'src/storage/types';\nimport { IVisitorCodeManager } from 'src/visitorCodeManager';\nimport { UrlProvider } from 'src/requester/urlProvider';\n\ninterface IClientConfiguration {\n initialize: (useCache?: boolean) => Promise<Result<void, KameleoonError>>;\n onConfigurationUpdate: (callback: () => void) => void;\n readonly featureFlags: Map<string, FeatureFlagType>;\n readonly configuration: ConfigurationType;\n readonly segments: Map<string, SegmentType>;\n readonly ruleMap: Map<number, MappedRuleType>;\n}\n\nexport class ClientConfiguration implements IClientConfiguration {\n private configurationUpdateCallback?: () => void;\n private updateConfigurationIntervalId: NodeJS.Timer | null = null;\n private updateType: UpdateType = UpdateType.Idle;\n private configurationData: ClientConfigurationDataType =\n DEFAULT_CONFIGURATION_DATA;\n private featureFlagsData: Map<string, FeatureFlagType> = new Map();\n private isTargetedDeliveryRule: boolean | null = null;\n private segmentsData: Map<string, SegmentType> | null = null;\n private settings: ClientSettingsType;\n private lastUpdate: Date;\n private storage: IStorage<ClientDataType>;\n private offlineTrackingStorage: IStorage<OfflineTracking>;\n private requester: Requester;\n private eventSource: IEventSource;\n private externalClientConfiguration?: ConfigurationDataType;\n private mappedRules: Map<number, MappedRuleType> | null = null;\n private dataManager: DataManager;\n private visitorCodeManager: IVisitorCodeManager;\n\n constructor({\n settings,\n storage,\n requester,\n dataManager,\n externalClientConfiguration,\n offlineTrackingStorage,\n eventSource,\n externalVisitorCodeManager,\n }: ClientConfigurationParametersType) {\n this.requester = requester;\n this.settings = settings;\n this.lastUpdate = new Date();\n this.storage = storage;\n this.dataManager = dataManager;\n this.externalClientConfiguration = externalClientConfiguration;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.visitorCodeManager = externalVisitorCodeManager;\n this.eventSource = eventSource;\n }\n\n public async initialize(): Promise<Result<void, KameleoonError>> {\n this.readStorageData();\n\n const isExternalConfiguration = Boolean(this.externalClientConfiguration);\n const shouldUpdate = this.checkShouldUpdate(isExternalConfiguration);\n\n if (shouldUpdate) {\n const updateResult = await this.updateClientConfiguration();\n\n if (!updateResult.ok) {\n return updateResult;\n }\n\n // --- Note ---\n // If update type is being toggled `initialize` will be called again\n // so we don't need to continue execution here\n const isUpdateTypeToggled = updateResult.data;\n\n if (isUpdateTypeToggled) {\n return Ok();\n }\n }\n\n if (isExternalConfiguration) {\n this.handleExternalUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.RealTime && !this.eventSource.isOpen) {\n this.updateType = UpdateType.Idle;\n this.handleRealTimeUpdates();\n\n return Ok();\n }\n\n if (this.updateType === UpdateType.Polling) {\n this.handlePollingUpdates();\n }\n\n return Ok();\n }\n\n private cleanupHandlers(): void {\n if (this.eventSource.isOpen) {\n this.eventSource.close();\n }\n\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n }\n\n private handleExternalUpdates(): void {\n this.cleanupHandlers();\n\n const { customData, configuration } = this.externalClientConfiguration!;\n this.configurationData = { customData, configuration };\n\n for (const featureFlag of this.featureFlags.values()) {\n this.featureFlagsData.set(featureFlag.featureKey, featureFlag);\n }\n }\n\n private handleRealTimeUpdates(): void {\n this.cleanupHandlers();\n\n const updateEventCallback = (timestamp: number) => {\n this.updateClientConfiguration(timestamp).then((updateResult) => {\n if (updateResult.ok && this.configurationUpdateCallback) {\n this.configurationUpdateCallback();\n }\n });\n };\n\n this.eventSource.open(updateEventCallback);\n }\n\n private handlePollingUpdates(): void {\n // --- Note ---\n // If `initialize` is called again the interval will be cleared\n // so theoretically we will constantly defer config update\n // but `this.lastUpdate` with `checkShouldUpdate` will prevent that\n this.cleanupHandlers();\n\n // --- Note ---\n // Error Handling is for `setInterval` emergency cleanup\n try {\n this.updateConfigurationIntervalId = setInterval(\n this.updateClientConfiguration.bind(this),\n this.settings.updateInterval,\n );\n } catch (err) {\n if (this.updateConfigurationIntervalId) {\n clearInterval(this.updateConfigurationIntervalId);\n }\n\n throw err;\n }\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n this.configurationUpdateCallback = callback;\n }\n\n get featureFlags(): Map<string, FeatureFlagType> {\n return this.featureFlagsData;\n }\n\n get configuration(): ConfigurationType {\n return this.configurationData.configuration;\n }\n\n get segments(): Map<string, SegmentType> {\n if (this.segmentsData) {\n return this.segmentsData;\n }\n\n const segmentsData = new Map<string, SegmentType>();\n\n this.featureFlagsData.forEach((flag) => {\n flag.rules.forEach((rule) => {\n if (rule.segment && !segmentsData.has(rule.segment.id)) {\n segmentsData.set(rule.segment.id, rule.segment);\n }\n });\n });\n\n this.segmentsData = segmentsData;\n\n return segmentsData;\n }\n\n get ruleMap(): Map<number, MappedRuleType> {\n if (this.mappedRules) {\n return this.mappedRules;\n }\n\n const mappedRules = new Map<number, MappedRuleType>();\n\n for (const featureFlag of this.featureFlags.values()) {\n for (const rule of featureFlag.rules) {\n const { id, experimentId, variationByExposition } = rule;\n const variationMap = new Map<string, number>();\n\n variationByExposition.forEach(({ variationKey, variationId }) => {\n if (typeof variationId === 'number') {\n variationMap.set(variationKey, variationId);\n }\n });\n\n mappedRules.set(id, {\n featureId: featureFlag.id,\n experimentId,\n variations: variationMap,\n });\n }\n }\n\n this.mappedRules = mappedRules;\n\n return mappedRules;\n }\n\n get isConsentRequired(): boolean {\n return this.configuration.consentType === ConsentType.Required;\n }\n\n get hasAnyTargetedDeliveryRule(): boolean {\n if (this.isTargetedDeliveryRule !== null) {\n return this.isTargetedDeliveryRule;\n }\n\n for (const featureFlag of this.featureFlags.values()) {\n if (\n featureFlag.environmentEnabled &&\n featureFlag.rules.some(\n (rule) => rule.type === RuleType.TARGETED_DELIVERY,\n )\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n // --- Note ---\n // Integrity check covers most of the migration scenarios\n // however in the future it will be changed to a dedicate migration\n // block that can handle all versions migrations\n private checkIntegrity(data: ConfigurationDataType | undefined): boolean {\n if (!data) {\n return false;\n }\n\n const fields = Object.keys(data);\n\n if (!fields.length) {\n return false;\n }\n\n const requiredFields = Object.keys(DEFAULT_CLIENT_CONFIGURATION);\n\n return fields.sort().join() === requiredFields.sort().join();\n }\n\n private checkShouldUpdate(skipChecks = false): boolean {\n const { configuration } = this.configurationData;\n const { updateInterval } = this.settings;\n\n // --- Note ---\n // Following `updateType` logic is done for client side\n // edge cases where we have previous campaigns on storage already, but we still want\n // to initialize SSE/Polling after page reload\n if (skipChecks) {\n this.updateType = UpdateType.Idle;\n\n return false;\n }\n\n this.updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n if (!this.featureFlags.size) {\n return true;\n }\n\n const lastUpdateTime = this.lastUpdate.getTime();\n const updateWindowEdge = Date.now() - updateInterval;\n\n return lastUpdateTime < updateWindowEdge;\n }\n\n private readStorageData(): void {\n const result = this.storage.read();\n\n if (result.ok) {\n const { data, lastUpdate } = result.data;\n\n const isStorageValid = this.checkIntegrity(data);\n\n // --- Note ---\n // Cleaning up storage if it's not valid for migration purposes\n if (!isStorageValid) {\n UrlProvider.setDataApiDomain(\n DEFAULT_CONFIGURATION_DATA.configuration.dataApiDomain,\n );\n\n const data = {\n ...DEFAULT_CONFIGURATION_DATA,\n featureFlags: [],\n };\n\n this.storage.write({\n data,\n lastUpdate: this.lastUpdate.toString(),\n });\n\n this.configurationData = DEFAULT_CONFIGURATION_DATA;\n } else {\n UrlProvider.setDataApiDomain(data.configuration.dataApiDomain);\n\n this.configurationData = data;\n this.lastUpdate = new Date(Date.parse(lastUpdate));\n }\n }\n }\n\n /**\n * Updates client configuration\n *\n * @param timeStamp - timestamp for real-time configuration update\n *\n * @returns `true` if current update type should be toggled (SSE/Polling)\n */\n private async updateClientConfiguration(\n timestamp?: number,\n ): Promise<Result<boolean, KameleoonError>> {\n const clientConfigurationResult =\n await this.requester.getClientConfiguration(timestamp);\n\n if (!clientConfigurationResult.ok) {\n if (this.featureFlags.size) {\n // TODO: the case of silent fail should be logged when logging is implemented\n return Ok(true);\n }\n\n return clientConfigurationResult;\n }\n\n Utilities.sendOfflineTracking({\n storage: this.offlineTrackingStorage,\n requester: this.requester,\n });\n\n const { configuration, customData, featureFlags } =\n clientConfigurationResult.data;\n\n this.configurationData = { configuration, customData };\n\n for (const featureFlag of featureFlags) {\n this.featureFlagsData.set(featureFlag.featureKey, featureFlag);\n }\n\n if (customData?.length) {\n this.dataManager.customDataIndexes = customData;\n }\n\n this.dataManager.clearTrees();\n this.mappedRules?.clear();\n this.isTargetedDeliveryRule = null;\n this.segmentsData = null;\n\n const result = this.updateStorageData();\n\n if (!result.ok) {\n return result;\n }\n\n const updateType = configuration.realTimeUpdate\n ? UpdateType.RealTime\n : UpdateType.Polling;\n\n const toggleUpdateType = updateType !== this.updateType;\n\n if (toggleUpdateType) {\n this.updateType = updateType;\n await this.initialize();\n }\n\n // --- Note ---\n // Regarding GDPR policy we should set visitorCode if legal consent isn't required\n // or we have at least one Targeted Delivery rule in configuration\n const consentRequired =\n this.isConsentRequired && !this.hasAnyTargetedDeliveryRule;\n this.visitorCodeManager.consentRequired = consentRequired;\n\n return Ok(toggleUpdateType);\n }\n\n private updateStorageData(): Result<void, KameleoonError> {\n this.lastUpdate = new Date();\n\n const configurationData = {\n ...this.configurationData,\n featureFlags: Array.from(this.featureFlags.values()),\n };\n\n const data: ClientDataType = {\n data: configurationData,\n lastUpdate: this.lastUpdate.toString(),\n };\n\n UrlProvider.setDataApiDomain(\n this.configurationData.configuration.dataApiDomain,\n );\n\n return this.storage.write(data);\n }\n}\n"],"mappings":"y3CAqCO,KAAM,CAAAA,mBAAoD,CAoB/DC,WAAWA,CAAAC,CAAA,CAS2B,IAT1B,CACVC,QAAQ,CAARA,CAAQ,CACRC,OAAO,CAAPA,CAAO,CACPC,SAAS,CAATA,CAAS,CACTC,WAAW,CAAXA,CAAW,CACXC,2BAA2B,CAA3BA,CAA2B,CAC3BC,sBAAsB,CAAtBA,CAAsB,CACtBC,WAAW,CAAXA,CAAW,CACXC,0BAA0B,CAA1BA,CACiC,CAAC,CAAAR,CAAA,CAAAS,eAAA,4CAAAA,eAAA,sCA3ByB,IAAI,EAAAA,eAAA,mBAChCC,iBAAU,CAACC,IAAI,EAAAF,eAAA,0BAE9CG,qCAA0B,EAAAH,eAAA,yBAC6B,GAAI,CAAAI,GAAK,EAAAJ,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,eAAe,CAAGA,CAAe,CAElD,GAAAlG,SAAE,EAACiG,CAAgB,CAC5B,CAEQD,iBAAiBA,CAAA,CAAiC,CACxD,IAAI,CAAC7G,UAAU,CAAG,GAAI,CAAAC,IAAM,MAEtB,CAAA0B,CAAiB,CAAAsE,aAAA,CAAAA,aAAA,IAClB,IAAI,CAACtE,iBAAiB,MACzBE,YAAY,CAAEmF,KAAK,CAACC,IAAI,CAAC,IAAI,CAACpF,YAAY,CAACC,MAAM,CAAC,CAAC,CAAC,EACrD,CAEKlB,CAAoB,CAAG,CAC3BA,IAAI,CAAEe,CAAiB,CACvB3B,UAAU,CAAE,IAAI,CAACA,UAAU,CAACmG,QAAQ,CAAC,CACvC,CAAC,CAMD,MAJA,CAAAL,wBAAW,CAACC,gBAAgB,CAC1B,IAAI,CAACpE,iBAAiB,CAACD,aAAa,CAACsE,aACvC,CAAC,CAEM,IAAI,CAAC5G,OAAO,CAAC8G,KAAK,CAACtF,CAAI,CAChC,CACF,CAACsG,OAAA,CAAAlI,mBAAA,CAAAA,mBAAA"}
@@ -1,2 +1,3 @@
1
- import { ConfigurationDataType } from '../clientConfiguration';
2
- export declare const DEFAULT_CONFIGURATION_DATA: ConfigurationDataType;
1
+ import { ClientConfigurationDataType, ConfigurationDataType } from '../clientConfiguration';
2
+ export declare const DEFAULT_CONFIGURATION_DATA: ClientConfigurationDataType;
3
+ export declare const DEFAULT_CLIENT_CONFIGURATION: ConfigurationDataType;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_CONFIGURATION_DATA=void 0;var _types=require("./types"),_requester=require("../requester");const DEFAULT_CONFIGURATION_DATA=exports.DEFAULT_CONFIGURATION_DATA={featureFlags:[],customData:[],configuration:{realTimeUpdate:!1,consentType:_types.ConsentType.NotRequired,dataApiDomain:_requester.DATA_API_DOMAIN}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_CONFIGURATION_DATA=exports.DEFAULT_CLIENT_CONFIGURATION=void 0;var _types=require("./types"),_requester=require("../requester");const DEFAULT_CONFIGURATION_DATA=exports.DEFAULT_CONFIGURATION_DATA={customData:[],configuration:{realTimeUpdate:!1,consentType:_types.ConsentType.NotRequired,dataApiDomain:_requester.DATA_API_DOMAIN}},DEFAULT_CLIENT_CONFIGURATION=exports.DEFAULT_CLIENT_CONFIGURATION={customData:[],featureFlags:[],configuration:{realTimeUpdate:!1,consentType:_types.ConsentType.NotRequired,dataApiDomain:_requester.DATA_API_DOMAIN}};
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["DEFAULT_CONFIGURATION_DATA","exports","featureFlags","customData","configuration","realTimeUpdate","consentType","ConsentType","NotRequired","dataApiDomain","DATA_API_DOMAIN"],"sources":["../../src/clientConfiguration/constants.ts"],"sourcesContent":["import { ConfigurationDataType } from 'src/clientConfiguration';\nimport { ConsentType } from './types';\nimport { DATA_API_DOMAIN } from 'src/requester';\n\nexport const DEFAULT_CONFIGURATION_DATA: ConfigurationDataType = {\n featureFlags: [],\n customData: [],\n configuration: {\n realTimeUpdate: false,\n consentType: ConsentType.NotRequired,\n dataApiDomain: DATA_API_DOMAIN,\n },\n};\n"],"mappings":"+KAIO,KAAM,CAAAA,0BAAiD,CAAAC,OAAA,CAAAD,0BAAA,CAAG,CAC/DE,YAAY,CAAE,EAAE,CAChBC,UAAU,CAAE,EAAE,CACdC,aAAa,CAAE,CACbC,cAAc,GAAO,CACrBC,WAAW,CAAEC,kBAAW,CAACC,WAAW,CACpCC,aAAa,CAAEC,0BACjB,CACF,CAAC"}
1
+ {"version":3,"file":"constants.js","names":["DEFAULT_CONFIGURATION_DATA","exports","customData","configuration","realTimeUpdate","consentType","ConsentType","NotRequired","dataApiDomain","DATA_API_DOMAIN","DEFAULT_CLIENT_CONFIGURATION","featureFlags"],"sources":["../../src/clientConfiguration/constants.ts"],"sourcesContent":["import {\n ClientConfigurationDataType,\n ConfigurationDataType,\n} from 'src/clientConfiguration';\nimport { ConsentType } from './types';\nimport { DATA_API_DOMAIN } from 'src/requester';\n\nexport const DEFAULT_CONFIGURATION_DATA: ClientConfigurationDataType = {\n customData: [],\n configuration: {\n realTimeUpdate: false,\n consentType: ConsentType.NotRequired,\n dataApiDomain: DATA_API_DOMAIN,\n },\n};\n\nexport const DEFAULT_CLIENT_CONFIGURATION: ConfigurationDataType = {\n customData: [],\n featureFlags: [],\n configuration: {\n realTimeUpdate: false,\n consentType: ConsentType.NotRequired,\n dataApiDomain: DATA_API_DOMAIN,\n },\n};\n"],"mappings":"yNAOa,CAAAA,0BAAuD,CAAAC,OAAA,CAAAD,0BAAA,CAAG,CACrEE,UAAU,CAAE,EAAE,CACdC,aAAa,CAAE,CACbC,cAAc,GAAO,CACrBC,WAAW,CAAEC,kBAAW,CAACC,WAAW,CACpCC,aAAa,CAAEC,0BACjB,CACF,CAAC,CAEYC,4BAAmD,CAAAT,OAAA,CAAAS,4BAAA,CAAG,CACjER,UAAU,CAAE,EAAE,CACdS,YAAY,CAAE,EAAE,CAChBR,aAAa,CAAE,CACbC,cAAc,GAAO,CACrBC,WAAW,CAAEC,kBAAW,CAACC,WAAW,CACpCC,aAAa,CAAEC,0BACjB,CACF,CAAC"}
@@ -1,2 +1,2 @@
1
- export { ConfigurationDataType, CustomDataConfigurationType, CustomDataScope, VariationByExpositionType, FeatureVariableType, FeatureFlagType, ConsentType, RuleItemType, JSONValue, RuleType, JSONType, } from './types';
1
+ export { ConfigurationDataType, CustomDataConfigurationType, ClientConfigurationDataType, CustomDataScope, VariationByExpositionType, FeatureVariableType, FeatureFlagType, ConsentType, RuleItemType, JSONValue, RuleType, JSONType, } from './types';
2
2
  export { ClientConfiguration } from './clientConfiguration';
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ClientConfiguration",{enumerable:!0,get:function(){return _clientConfiguration.ClientConfiguration}}),Object.defineProperty(exports,"ConfigurationDataType",{enumerable:!0,get:function(){return _types.ConfigurationDataType}}),Object.defineProperty(exports,"ConsentType",{enumerable:!0,get:function(){return _types.ConsentType}}),Object.defineProperty(exports,"CustomDataConfigurationType",{enumerable:!0,get:function(){return _types.CustomDataConfigurationType}}),Object.defineProperty(exports,"CustomDataScope",{enumerable:!0,get:function(){return _types.CustomDataScope}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureVariableType",{enumerable:!0,get:function(){return _types.FeatureVariableType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function(){return _types.JSONType}}),Object.defineProperty(exports,"JSONValue",{enumerable:!0,get:function(){return _types.JSONValue}}),Object.defineProperty(exports,"RuleItemType",{enumerable:!0,get:function(){return _types.RuleItemType}}),Object.defineProperty(exports,"RuleType",{enumerable:!0,get:function(){return _types.RuleType}}),Object.defineProperty(exports,"VariationByExpositionType",{enumerable:!0,get:function(){return _types.VariationByExpositionType}});var _types=require("./types"),_clientConfiguration=require("./clientConfiguration");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ClientConfiguration",{enumerable:!0,get:function(){return _clientConfiguration.ClientConfiguration}}),Object.defineProperty(exports,"ClientConfigurationDataType",{enumerable:!0,get:function(){return _types.ClientConfigurationDataType}}),Object.defineProperty(exports,"ConfigurationDataType",{enumerable:!0,get:function(){return _types.ConfigurationDataType}}),Object.defineProperty(exports,"ConsentType",{enumerable:!0,get:function(){return _types.ConsentType}}),Object.defineProperty(exports,"CustomDataConfigurationType",{enumerable:!0,get:function(){return _types.CustomDataConfigurationType}}),Object.defineProperty(exports,"CustomDataScope",{enumerable:!0,get:function(){return _types.CustomDataScope}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureVariableType",{enumerable:!0,get:function(){return _types.FeatureVariableType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function(){return _types.JSONType}}),Object.defineProperty(exports,"JSONValue",{enumerable:!0,get:function(){return _types.JSONValue}}),Object.defineProperty(exports,"RuleItemType",{enumerable:!0,get:function(){return _types.RuleItemType}}),Object.defineProperty(exports,"RuleType",{enumerable:!0,get:function(){return _types.RuleType}}),Object.defineProperty(exports,"VariationByExpositionType",{enumerable:!0,get:function(){return _types.VariationByExpositionType}});var _types=require("./types"),_clientConfiguration=require("./clientConfiguration");
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/clientConfiguration/index.ts"],"sourcesContent":["export {\n ConfigurationDataType,\n CustomDataConfigurationType,\n CustomDataScope,\n VariationByExpositionType,\n FeatureVariableType,\n FeatureFlagType,\n ConsentType,\n RuleItemType,\n JSONValue,\n RuleType,\n JSONType,\n} from './types';\nexport { ClientConfiguration } from './clientConfiguration';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/clientConfiguration/index.ts"],"sourcesContent":["export {\n ConfigurationDataType,\n CustomDataConfigurationType,\n ClientConfigurationDataType,\n CustomDataScope,\n VariationByExpositionType,\n FeatureVariableType,\n FeatureFlagType,\n ConsentType,\n RuleItemType,\n JSONValue,\n RuleType,\n JSONType,\n} from './types';\nexport { ClientConfiguration } from './clientConfiguration';\n"],"mappings":""}
@@ -95,6 +95,7 @@ export type ConfigurationDataType = {
95
95
  configuration: ConfigurationType;
96
96
  customData: CustomDataConfigurationType[];
97
97
  };
98
+ export type ClientConfigurationDataType = Omit<ConfigurationDataType, 'featureFlags'>;
98
99
  export type CustomDataConfigurationType = {
99
100
  index: number;
100
101
  localOnly: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["UpdateType","exports","Polling","RealTime","Idle","RuleType","TARGETED_DELIVERY","EXPERIMENTATION","FeatureFlagSdkLanguageType","ANDROID","SWIFT","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACTJS","FeatureStatus","ACTIVATED","DEACTIVATED","SCHEDULED","CustomDataScope","Visit","Visitor","Page","ConsentType","Required","NotRequired"],"sources":["../../src/clientConfiguration/types.ts"],"sourcesContent":["import { ClientSettingsType } from 'src/clientSettings';\nimport { IEventSource } from 'src/eventSource';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { IVisitorCodeManager } from 'src/visitorCodeManager';\nimport { ClientDataType, IStorage, OfflineTracking } from 'src/storage';\nimport { SegmentType } from 'src/targeting';\nimport { VariableType } from 'src/types';\n\nexport type ScheduleType = {\n dateStart: string;\n dateEnd: string;\n};\n\nexport enum UpdateType {\n Polling,\n RealTime,\n Idle,\n}\n\nexport type JSONValue =\n | string\n | number\n | boolean\n | { [x: string]: JSONValue }\n | JSONValue[];\n\nexport type JSONType = Record<string | number | symbol, JSONValue> | null;\n\nexport enum RuleType {\n TARGETED_DELIVERY = 'TARGETED_DELIVERY',\n EXPERIMENTATION = 'EXPERIMENTATION',\n}\n\nexport enum FeatureFlagSdkLanguageType {\n ANDROID = 'ANDROID',\n SWIFT = 'SWIFT',\n JAVA = 'JAVA',\n CSHARP = 'CSHARP',\n NODEJS = 'NODEJS',\n PHP = 'PHP',\n RUBY = 'RUBY',\n GO = 'GO',\n FLUTTER = 'FLUTTER',\n REACTJS = 'REACTJS',\n}\n\nexport enum FeatureStatus {\n ACTIVATED = 'ACTIVATED',\n DEACTIVATED = 'DEACTIVATED',\n SCHEDULED = 'SCHEDULED',\n}\n\nexport enum CustomDataScope {\n Visit = 'VISIT',\n Visitor = 'VISITOR',\n Page = 'Page',\n}\n\nexport enum ConsentType {\n Required = 'REQUIRED',\n NotRequired = 'NOT_REQUIRED',\n}\n\nexport type DeviationType = {\n variationId: string;\n value: number;\n};\n\nexport type FeatureFlagType = {\n id: number;\n featureKey: string;\n environmentEnabled: boolean;\n variations: FeatureVariationType[];\n defaultVariationKey: string;\n rules: RuleItemType[];\n};\n\nexport type FeatureVariationType = {\n key: string;\n variables: FeatureVariableType[];\n};\n\nexport type FeatureVariableType = {\n key: string;\n type: VariableType;\n value: string | number | boolean;\n};\n\nexport type RuleItemType = {\n type: RuleType;\n id: number;\n respoolTime: number | null;\n order: number;\n exposition: number;\n experimentId: number;\n variationByExposition: VariationByExpositionType[];\n segment: SegmentType | null;\n};\n\nexport type MappedRuleType = {\n experimentId: number;\n featureId: number;\n // --- Note ---\n // Map<variationKey, variationId>\n variations: Map<string, number>;\n};\n\nexport type VariationByExpositionType = {\n variationKey: string;\n variationId: number;\n exposition: number;\n};\n\nexport type ConfigurationDataType = {\n featureFlags: FeatureFlagType[];\n configuration: ConfigurationType;\n customData: CustomDataConfigurationType[];\n};\n\nexport type CustomDataConfigurationType = {\n index: number;\n localOnly: boolean;\n isMappingIdentifier: boolean;\n scope: CustomDataScope;\n};\n\nexport type ConfigurationType = {\n realTimeUpdate: boolean;\n consentType: ConsentType;\n dataApiDomain: string;\n};\n\nexport type ClientConfigurationParametersType = {\n settings: ClientSettingsType;\n storage: IStorage<ClientDataType>;\n dataManager: DataManager;\n requester: Requester;\n eventSource: IEventSource;\n offlineTrackingStorage: IStorage<OfflineTracking>;\n externalClientConfiguration?: ConfigurationDataType;\n externalVisitorCodeManager: IVisitorCodeManager;\n};\n"],"mappings":"uNAcY,CAAAA,UAAU,CAAAC,OAAA,CAAAD,UAAA,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAVA,CAAU,CAAAE,OAAA,cAAVF,CAAU,CAAVA,CAAU,CAAAG,QAAA,eAAVH,CAAU,CAAVA,CAAU,CAAAI,IAAA,WAAVJ,CAAU,MAeVK,QAAQ,CAAAJ,OAAA,CAAAI,QAAA,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAC,iBAAA,qBAARD,CAAQ,CAAAE,eAAA,mBAARF,CAAQ,MAKRG,0BAA0B,CAAAP,OAAA,CAAAO,0BAAA,UAA1BA,CAA0B,QAA1B,CAAAA,CAA0B,CAAAC,OAAA,WAA1BD,CAA0B,CAAAE,KAAA,SAA1BF,CAA0B,CAAAG,IAAA,QAA1BH,CAA0B,CAAAI,MAAA,UAA1BJ,CAA0B,CAAAK,MAAA,UAA1BL,CAA0B,CAAAM,GAAA,OAA1BN,CAA0B,CAAAO,IAAA,QAA1BP,CAA0B,CAAAQ,EAAA,MAA1BR,CAA0B,CAAAS,OAAA,WAA1BT,CAA0B,CAAAU,OAAA,WAA1BV,CAA0B,MAa1BW,aAAa,CAAAlB,OAAA,CAAAkB,aAAA,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,SAAA,aAAbD,CAAa,CAAAE,WAAA,eAAbF,CAAa,CAAAG,SAAA,aAAbH,CAAa,MAMbI,eAAe,CAAAtB,OAAA,CAAAsB,eAAA,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,KAAA,SAAfD,CAAe,CAAAE,OAAA,WAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,MAMfI,WAAW,CAAA1B,OAAA,CAAA0B,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,QAAA,YAAXD,CAAW,CAAAE,WAAA,gBAAXF,CAAW"}
1
+ {"version":3,"file":"types.js","names":["UpdateType","exports","Polling","RealTime","Idle","RuleType","TARGETED_DELIVERY","EXPERIMENTATION","FeatureFlagSdkLanguageType","ANDROID","SWIFT","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACTJS","FeatureStatus","ACTIVATED","DEACTIVATED","SCHEDULED","CustomDataScope","Visit","Visitor","Page","ConsentType","Required","NotRequired"],"sources":["../../src/clientConfiguration/types.ts"],"sourcesContent":["import { ClientSettingsType } from 'src/clientSettings';\nimport { IEventSource } from 'src/eventSource';\nimport { DataManager } from 'src/kameleoonData';\nimport { Requester } from 'src/requester';\nimport { IVisitorCodeManager } from 'src/visitorCodeManager';\nimport { ClientDataType, IStorage, OfflineTracking } from 'src/storage';\nimport { SegmentType } from 'src/targeting';\nimport { VariableType } from 'src/types';\n\nexport type ScheduleType = {\n dateStart: string;\n dateEnd: string;\n};\n\nexport enum UpdateType {\n Polling,\n RealTime,\n Idle,\n}\n\nexport type JSONValue =\n | string\n | number\n | boolean\n | { [x: string]: JSONValue }\n | JSONValue[];\n\nexport type JSONType = Record<string | number | symbol, JSONValue> | null;\n\nexport enum RuleType {\n TARGETED_DELIVERY = 'TARGETED_DELIVERY',\n EXPERIMENTATION = 'EXPERIMENTATION',\n}\n\nexport enum FeatureFlagSdkLanguageType {\n ANDROID = 'ANDROID',\n SWIFT = 'SWIFT',\n JAVA = 'JAVA',\n CSHARP = 'CSHARP',\n NODEJS = 'NODEJS',\n PHP = 'PHP',\n RUBY = 'RUBY',\n GO = 'GO',\n FLUTTER = 'FLUTTER',\n REACTJS = 'REACTJS',\n}\n\nexport enum FeatureStatus {\n ACTIVATED = 'ACTIVATED',\n DEACTIVATED = 'DEACTIVATED',\n SCHEDULED = 'SCHEDULED',\n}\n\nexport enum CustomDataScope {\n Visit = 'VISIT',\n Visitor = 'VISITOR',\n Page = 'Page',\n}\n\nexport enum ConsentType {\n Required = 'REQUIRED',\n NotRequired = 'NOT_REQUIRED',\n}\n\nexport type DeviationType = {\n variationId: string;\n value: number;\n};\n\nexport type FeatureFlagType = {\n id: number;\n featureKey: string;\n environmentEnabled: boolean;\n variations: FeatureVariationType[];\n defaultVariationKey: string;\n rules: RuleItemType[];\n};\n\nexport type FeatureVariationType = {\n key: string;\n variables: FeatureVariableType[];\n};\n\nexport type FeatureVariableType = {\n key: string;\n type: VariableType;\n value: string | number | boolean;\n};\n\nexport type RuleItemType = {\n type: RuleType;\n id: number;\n respoolTime: number | null;\n order: number;\n exposition: number;\n experimentId: number;\n variationByExposition: VariationByExpositionType[];\n segment: SegmentType | null;\n};\n\nexport type MappedRuleType = {\n experimentId: number;\n featureId: number;\n // --- Note ---\n // Map<variationKey, variationId>\n variations: Map<string, number>;\n};\n\nexport type VariationByExpositionType = {\n variationKey: string;\n variationId: number;\n exposition: number;\n};\n\nexport type ConfigurationDataType = {\n featureFlags: FeatureFlagType[];\n configuration: ConfigurationType;\n customData: CustomDataConfigurationType[];\n};\n\nexport type ClientConfigurationDataType = Omit<\n ConfigurationDataType,\n 'featureFlags'\n>;\n\nexport type CustomDataConfigurationType = {\n index: number;\n localOnly: boolean;\n isMappingIdentifier: boolean;\n scope: CustomDataScope;\n};\n\nexport type ConfigurationType = {\n realTimeUpdate: boolean;\n consentType: ConsentType;\n dataApiDomain: string;\n};\n\nexport type ClientConfigurationParametersType = {\n settings: ClientSettingsType;\n storage: IStorage<ClientDataType>;\n dataManager: DataManager;\n requester: Requester;\n eventSource: IEventSource;\n offlineTrackingStorage: IStorage<OfflineTracking>;\n externalClientConfiguration?: ConfigurationDataType;\n externalVisitorCodeManager: IVisitorCodeManager;\n};\n"],"mappings":"uNAcY,CAAAA,UAAU,CAAAC,OAAA,CAAAD,UAAA,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAVA,CAAU,CAAAE,OAAA,cAAVF,CAAU,CAAVA,CAAU,CAAAG,QAAA,eAAVH,CAAU,CAAVA,CAAU,CAAAI,IAAA,WAAVJ,CAAU,MAeVK,QAAQ,CAAAJ,OAAA,CAAAI,QAAA,UAARA,CAAQ,QAAR,CAAAA,CAAQ,CAAAC,iBAAA,qBAARD,CAAQ,CAAAE,eAAA,mBAARF,CAAQ,MAKRG,0BAA0B,CAAAP,OAAA,CAAAO,0BAAA,UAA1BA,CAA0B,QAA1B,CAAAA,CAA0B,CAAAC,OAAA,WAA1BD,CAA0B,CAAAE,KAAA,SAA1BF,CAA0B,CAAAG,IAAA,QAA1BH,CAA0B,CAAAI,MAAA,UAA1BJ,CAA0B,CAAAK,MAAA,UAA1BL,CAA0B,CAAAM,GAAA,OAA1BN,CAA0B,CAAAO,IAAA,QAA1BP,CAA0B,CAAAQ,EAAA,MAA1BR,CAA0B,CAAAS,OAAA,WAA1BT,CAA0B,CAAAU,OAAA,WAA1BV,CAA0B,MAa1BW,aAAa,CAAAlB,OAAA,CAAAkB,aAAA,UAAbA,CAAa,QAAb,CAAAA,CAAa,CAAAC,SAAA,aAAbD,CAAa,CAAAE,WAAA,eAAbF,CAAa,CAAAG,SAAA,aAAbH,CAAa,MAMbI,eAAe,CAAAtB,OAAA,CAAAsB,eAAA,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,KAAA,SAAfD,CAAe,CAAAE,OAAA,WAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,MAMfI,WAAW,CAAA1B,OAAA,CAAA0B,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAC,QAAA,YAAXD,CAAW,CAAAE,WAAA,gBAAXF,CAAW"}
package/dist/constants.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WAREHOUSE_AUDIENCE_KEY=exports.VISITOR_CODE_LENGTH=exports.SdkLanguageType=exports.OFF_VARIATION_KEY=exports.DEFAULT_VISITOR_DATA_FILTERS=exports.CACHE_ITEM_LIFETIME=exports.CACHE_CLEANUP_TIMEOUT=void 0;const OFF_VARIATION_KEY=exports.OFF_VARIATION_KEY="off",WAREHOUSE_AUDIENCE_KEY=exports.WAREHOUSE_AUDIENCE_KEY="warehouseAudiences",VISITOR_CODE_LENGTH=exports.VISITOR_CODE_LENGTH=16,CACHE_CLEANUP_TIMEOUT=exports.CACHE_CLEANUP_TIMEOUT=10,CACHE_ITEM_LIFETIME=exports.CACHE_ITEM_LIFETIME=5;let SdkLanguageType=exports.SdkLanguageType=function(a){return a.ANDROID="ANDROID",a.IOS="IOS",a.JAVA="JAVA",a.CSHARP="CSHARP",a.NODEJS="NODEJS",a.PHP="PHP",a.RUBY="RUBY",a.GO="GO",a.FLUTTER="FLUTTER",a.REACT="REACT",a.PYTHON="PYTHON",a.JAVASCRIPT="JAVASCRIPT",a.RUST="RUST",a}({});const DEFAULT_VISITOR_DATA_FILTERS=exports.DEFAULT_VISITOR_DATA_FILTERS={previousVisitAmount:1,currentVisit:!0,customData:!0,pageViews:!1,geolocation:!1,device:!1,browser:!1,operatingSystem:!1,conversions:!1,experiments:!1};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WAREHOUSE_AUDIENCE_KEY=exports.VISITOR_CODE_LENGTH=exports.SdkLanguageType=exports.OFF_VARIATION_KEY=exports.DEFAULT_VISITOR_DATA_FILTERS=exports.CACHE_ITEM_LIFETIME=exports.CACHE_CLEANUP_TIMEOUT=void 0;const OFF_VARIATION_KEY=exports.OFF_VARIATION_KEY="off",WAREHOUSE_AUDIENCE_KEY=exports.WAREHOUSE_AUDIENCE_KEY="warehouseAudiences",VISITOR_CODE_LENGTH=exports.VISITOR_CODE_LENGTH=16,CACHE_CLEANUP_TIMEOUT=exports.CACHE_CLEANUP_TIMEOUT=10,CACHE_ITEM_LIFETIME=exports.CACHE_ITEM_LIFETIME=5;let SdkLanguageType=exports.SdkLanguageType=function(a){return a.ANDROID="ANDROID",a.IOS="IOS",a.JAVA="JAVA",a.CSHARP="CSHARP",a.NODEJS="NODEJS",a.PHP="PHP",a.RUBY="RUBY",a.GO="GO",a.FLUTTER="FLUTTER",a.REACT="REACT",a.PYTHON="PYTHON",a.JAVASCRIPT="JAVASCRIPT",a.RUST="RUST",a}({});const DEFAULT_VISITOR_DATA_FILTERS=exports.DEFAULT_VISITOR_DATA_FILTERS={previousVisitAmount:1,currentVisit:!0,customData:!0,pageViews:!1,geolocation:!1,device:!1,browser:!1,operatingSystem:!1,conversions:!1,experiments:!1,kcs:!1};
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["OFF_VARIATION_KEY","exports","WAREHOUSE_AUDIENCE_KEY","VISITOR_CODE_LENGTH","CACHE_CLEANUP_TIMEOUT","CACHE_ITEM_LIFETIME","SdkLanguageType","ANDROID","IOS","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACT","PYTHON","JAVASCRIPT","RUST","DEFAULT_VISITOR_DATA_FILTERS","previousVisitAmount","currentVisit","customData","pageViews","geolocation","device","browser","operatingSystem","conversions","experiments"],"sources":["../src/constants.ts"],"sourcesContent":["import { VisitorDataFiltersType } from './utilities/types';\n\nexport const OFF_VARIATION_KEY = 'off';\nexport const WAREHOUSE_AUDIENCE_KEY = 'warehouseAudiences';\nexport const VISITOR_CODE_LENGTH = 16;\nexport const CACHE_CLEANUP_TIMEOUT = 10;\nexport const CACHE_ITEM_LIFETIME = 5;\n\n/**\n * @readonly\n * @enum {string} an Enum of all the possible Kameleoon SDK types\n * */\nexport enum SdkLanguageType {\n ANDROID = 'ANDROID',\n IOS = 'IOS',\n JAVA = 'JAVA',\n CSHARP = 'CSHARP',\n NODEJS = 'NODEJS',\n PHP = 'PHP',\n RUBY = 'RUBY',\n GO = 'GO',\n FLUTTER = 'FLUTTER',\n REACT = 'REACT',\n PYTHON = 'PYTHON',\n JAVASCRIPT = 'JAVASCRIPT',\n RUST = 'RUST',\n}\n\nexport const DEFAULT_VISITOR_DATA_FILTERS: VisitorDataFiltersType = {\n previousVisitAmount: 1,\n currentVisit: true,\n customData: true,\n pageViews: false,\n geolocation: false,\n device: false,\n browser: false,\n operatingSystem: false,\n conversions: false,\n experiments: false,\n};\n"],"mappings":"4RAEa,CAAAA,iBAAiB,CAAAC,OAAA,CAAAD,iBAAA,CAAG,KAAK,CACzBE,sBAAsB,CAAAD,OAAA,CAAAC,sBAAA,CAAG,oBAAoB,CAC7CC,mBAAmB,CAAAF,OAAA,CAAAE,mBAAA,CAAG,EAAE,CACxBC,qBAAqB,CAAAH,OAAA,CAAAG,qBAAA,CAAG,EAAE,CAC1BC,mBAAmB,CAAAJ,OAAA,CAAAI,mBAAA,CAAG,CAAC,IAMxB,CAAAC,eAAe,CAAAL,OAAA,CAAAK,eAAA,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,OAAA,WAAfD,CAAe,CAAAE,GAAA,OAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,CAAAI,MAAA,UAAfJ,CAAe,CAAAK,MAAA,UAAfL,CAAe,CAAAM,GAAA,OAAfN,CAAe,CAAAO,IAAA,QAAfP,CAAe,CAAAQ,EAAA,MAAfR,CAAe,CAAAS,OAAA,WAAfT,CAAe,CAAAU,KAAA,SAAfV,CAAe,CAAAW,MAAA,UAAfX,CAAe,CAAAY,UAAA,cAAfZ,CAAe,CAAAa,IAAA,QAAfb,CAAe,MAgBpB,KAAM,CAAAc,4BAAoD,CAAAnB,OAAA,CAAAmB,4BAAA,CAAG,CAClEC,mBAAmB,CAAE,CAAC,CACtBC,YAAY,GAAM,CAClBC,UAAU,GAAM,CAChBC,SAAS,GAAO,CAChBC,WAAW,GAAO,CAClBC,MAAM,GAAO,CACbC,OAAO,GAAO,CACdC,eAAe,GAAO,CACtBC,WAAW,GAAO,CAClBC,WAAW,GACb,CAAC"}
1
+ {"version":3,"file":"constants.js","names":["OFF_VARIATION_KEY","exports","WAREHOUSE_AUDIENCE_KEY","VISITOR_CODE_LENGTH","CACHE_CLEANUP_TIMEOUT","CACHE_ITEM_LIFETIME","SdkLanguageType","ANDROID","IOS","JAVA","CSHARP","NODEJS","PHP","RUBY","GO","FLUTTER","REACT","PYTHON","JAVASCRIPT","RUST","DEFAULT_VISITOR_DATA_FILTERS","previousVisitAmount","currentVisit","customData","pageViews","geolocation","device","browser","operatingSystem","conversions","experiments","kcs"],"sources":["../src/constants.ts"],"sourcesContent":["import { VisitorDataFiltersType } from './utilities/types';\n\nexport const OFF_VARIATION_KEY = 'off';\nexport const WAREHOUSE_AUDIENCE_KEY = 'warehouseAudiences';\nexport const VISITOR_CODE_LENGTH = 16;\nexport const CACHE_CLEANUP_TIMEOUT = 10;\nexport const CACHE_ITEM_LIFETIME = 5;\n\n/**\n * @readonly\n * @enum {string} an Enum of all the possible Kameleoon SDK types\n * */\nexport enum SdkLanguageType {\n ANDROID = 'ANDROID',\n IOS = 'IOS',\n JAVA = 'JAVA',\n CSHARP = 'CSHARP',\n NODEJS = 'NODEJS',\n PHP = 'PHP',\n RUBY = 'RUBY',\n GO = 'GO',\n FLUTTER = 'FLUTTER',\n REACT = 'REACT',\n PYTHON = 'PYTHON',\n JAVASCRIPT = 'JAVASCRIPT',\n RUST = 'RUST',\n}\n\nexport const DEFAULT_VISITOR_DATA_FILTERS: VisitorDataFiltersType = {\n previousVisitAmount: 1,\n currentVisit: true,\n customData: true,\n pageViews: false,\n geolocation: false,\n device: false,\n browser: false,\n operatingSystem: false,\n conversions: false,\n experiments: false,\n kcs: false,\n};\n"],"mappings":"4RAEa,CAAAA,iBAAiB,CAAAC,OAAA,CAAAD,iBAAA,CAAG,KAAK,CACzBE,sBAAsB,CAAAD,OAAA,CAAAC,sBAAA,CAAG,oBAAoB,CAC7CC,mBAAmB,CAAAF,OAAA,CAAAE,mBAAA,CAAG,EAAE,CACxBC,qBAAqB,CAAAH,OAAA,CAAAG,qBAAA,CAAG,EAAE,CAC1BC,mBAAmB,CAAAJ,OAAA,CAAAI,mBAAA,CAAG,CAAC,IAMxB,CAAAC,eAAe,CAAAL,OAAA,CAAAK,eAAA,UAAfA,CAAe,QAAf,CAAAA,CAAe,CAAAC,OAAA,WAAfD,CAAe,CAAAE,GAAA,OAAfF,CAAe,CAAAG,IAAA,QAAfH,CAAe,CAAAI,MAAA,UAAfJ,CAAe,CAAAK,MAAA,UAAfL,CAAe,CAAAM,GAAA,OAAfN,CAAe,CAAAO,IAAA,QAAfP,CAAe,CAAAQ,EAAA,MAAfR,CAAe,CAAAS,OAAA,WAAfT,CAAe,CAAAU,KAAA,SAAfV,CAAe,CAAAW,MAAA,UAAfX,CAAe,CAAAY,UAAA,cAAfZ,CAAe,CAAAa,IAAA,QAAfb,CAAe,MAgBpB,KAAM,CAAAc,4BAAoD,CAAAnB,OAAA,CAAAmB,4BAAA,CAAG,CAClEC,mBAAmB,CAAE,CAAC,CACtBC,YAAY,GAAM,CAClBC,UAAU,GAAM,CAChBC,SAAS,GAAO,CAChBC,WAAW,GAAO,CAClBC,MAAM,GAAO,CACbC,OAAO,GAAO,CACdC,eAAe,GAAO,CACtBC,WAAW,GAAO,CAClBC,WAAW,GAAO,CAClBC,GAAG,GACL,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { FeatureFlagVariationsType, KameleoonStorageKey, StorageDataType, IExter
8
8
  export { VisitorCodeManager, IVisitorCodeManager } from './visitorCodeManager';
9
9
  export { VISITOR_CODE_LENGTH, SdkLanguageType } from './constants';
10
10
  export { JSONType, ConfigurationDataType } from './clientConfiguration';
11
- export { Environment, VariableType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, ExternalPackageInfoType, FeatureFlagVariableType, TrackConversionParamsType, FeatureVariableResultType, RemoteVisitorDataParamsType, InternalSDKConfigurationType, SetDataCallbackParametersType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, Milliseconds, } from './types';
11
+ export { Environment, VariableType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, KameleoonVariationType, ExternalPackageInfoType, FeatureFlagVariableType, TrackConversionParamsType, FeatureVariableResultType, RemoteVisitorDataParamsType, InternalSDKConfigurationType, SetDataCallbackParametersType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, Milliseconds, } from './types';
12
12
  export { DEFAULT_CLEANUP_INTERVAL } from './kameleoonData';
13
13
  export { ApplicationVersion, CustomData, Conversion, Device, Cookie, Browser, UserAgent, DeviceType, CookieType, GeolocationData, GeolocationInfoType, OperatingSystemType, OperatingSystem, BrowserType, PageView, KameleoonData, KameleoonDataType, PageViewParametersType, ConversionParametersType, ApplicationVersionDataType, } from './kameleoonData';
14
14
  export { IExternalEventSource, EventSourceOpenParametersType, } from './eventSource';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function(){return _kameleoonData.ApplicationVersion}}),Object.defineProperty(exports,"ApplicationVersionDataType",{enumerable:!0,get:function(){return _kameleoonData.ApplicationVersionDataType}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function(){return _kameleoonData.Browser}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function(){return _kameleoonData.BrowserType}}),Object.defineProperty(exports,"ConfigurationDataType",{enumerable:!0,get:function(){return _clientConfiguration.ConfigurationDataType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function(){return _kameleoonData.Conversion}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function(){return _kameleoonData.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function(){return _kameleoonData.Cookie}}),Object.defineProperty(exports,"CookieType",{enumerable:!0,get:function(){return _kameleoonData.CookieType}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function(){return _kameleoonData.CustomData}}),Object.defineProperty(exports,"DEFAULT_CLEANUP_INTERVAL",{enumerable:!0,get:function(){return _kameleoonData.DEFAULT_CLEANUP_INTERVAL}}),Object.defineProperty(exports,"DEFAULT_REQUEST_TIMEOUT",{enumerable:!0,get:function(){return _requester.DEFAULT_REQUEST_TIMEOUT}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function(){return _kameleoonData.Device}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function(){return _kameleoonData.DeviceType}}),Object.defineProperty(exports,"Environment",{enumerable:!0,get:function(){return _types.Environment}}),Object.defineProperty(exports,"Err",{enumerable:!0,get:function(){return _tsRes.Err}}),Object.defineProperty(exports,"EventSourceOpenParametersType",{enumerable:!0,get:function(){return _eventSource.EventSourceOpenParametersType}}),Object.defineProperty(exports,"ExternalPackageInfoType",{enumerable:!0,get:function(){return _types.ExternalPackageInfoType}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureFlagVariableType",{enumerable:!0,get:function(){return _types.FeatureFlagVariableType}}),Object.defineProperty(exports,"FeatureFlagVariationsType",{enumerable:!0,get:function(){return _storage.FeatureFlagVariationsType}}),Object.defineProperty(exports,"FeatureVariableResultType",{enumerable:!0,get:function(){return _types.FeatureVariableResultType}}),Object.defineProperty(exports,"GeolocationData",{enumerable:!0,get:function(){return _kameleoonData.GeolocationData}}),Object.defineProperty(exports,"GeolocationInfoType",{enumerable:!0,get:function(){return _kameleoonData.GeolocationInfoType}}),Object.defineProperty(exports,"GetFeatureFlagVariableParamsType",{enumerable:!0,get:function(){return _types.GetFeatureFlagVariableParamsType}}),Object.defineProperty(exports,"GetVisitorWarehouseAudienceParamsType",{enumerable:!0,get:function(){return _types.GetVisitorWarehouseAudienceParamsType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function(){return _requester.Header}}),Object.defineProperty(exports,"HeadersType",{enumerable:!0,get:function(){return _requester.HeadersType}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function(){return _requester.HttpMethod}}),Object.defineProperty(exports,"IExternalEventSource",{enumerable:!0,get:function(){return _eventSource.IExternalEventSource}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function(){return _requester.IExternalRequestDispatcher}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function(){return _storage.IExternalStorage}}),Object.defineProperty(exports,"IKameleoonCore",{enumerable:!0,get:function(){return _kameleoonClientInterface.IKameleoonClient}}),Object.defineProperty(exports,"IVisitorCodeManager",{enumerable:!0,get:function(){return _visitorCodeManager.IVisitorCodeManager}}),Object.defineProperty(exports,"InternalSDKConfigurationType",{enumerable:!0,get:function(){return _types.InternalSDKConfigurationType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function(){return _clientConfiguration.JSONType}}),Object.defineProperty(exports,"KameleoonCore",{enumerable:!0,get:function(){return _kameleoonClient.KameleoonClient}}),Object.defineProperty(exports,"KameleoonCoreUtils",{enumerable:!0,get:function(){return _kameleoonUtils.KameleoonUtils}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function(){return _kameleoonData.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function(){return _kameleoonData.KameleoonDataType}}),Object.defineProperty(exports,"KameleoonError",{enumerable:!0,get:function(){return _kameleoonError.KameleoonError}}),Object.defineProperty(exports,"KameleoonException",{enumerable:!0,get:function(){return _kameleoonError.KameleoonException}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function(){return _storage.KameleoonStorageKey}}),Object.defineProperty(exports,"Milliseconds",{enumerable:!0,get:function(){return _types.Milliseconds}}),Object.defineProperty(exports,"NUMBER_OF_RETRIES",{enumerable:!0,get:function(){return _requester.NUMBER_OF_RETRIES}}),Object.defineProperty(exports,"Ok",{enumerable:!0,get:function(){return _tsRes.Ok}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function(){return _kameleoonData.OperatingSystem}}),Object.defineProperty(exports,"OperatingSystemType",{enumerable:!0,get:function(){return _kameleoonData.OperatingSystemType}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function(){return _kameleoonData.PageView}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function(){return _kameleoonData.PageViewParametersType}}),Object.defineProperty(exports,"RETRIES_DELAY",{enumerable:!0,get:function(){return _requester.RETRIES_DELAY}}),Object.defineProperty(exports,"RemoteVisitorDataParamsType",{enumerable:!0,get:function(){return _types.RemoteVisitorDataParamsType}}),Object.defineProperty(exports,"Result",{enumerable:!0,get:function(){return _tsRes.Result}}),Object.defineProperty(exports,"SDKConfigurationType",{enumerable:!0,get:function(){return _types.SDKConfigurationType}}),Object.defineProperty(exports,"SDKCoreParameters",{enumerable:!0,get:function(){return _types.SDKCoreParameters}}),Object.defineProperty(exports,"SdkLanguageType",{enumerable:!0,get:function(){return _constants.SdkLanguageType}}),Object.defineProperty(exports,"SetDataCallbackParametersType",{enumerable:!0,get:function(){return _types.SetDataCallbackParametersType}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function(){return _storage.StorageDataType}}),Object.defineProperty(exports,"TrackConversionParamsType",{enumerable:!0,get:function(){return _types.TrackConversionParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function(){return _requester.TrackParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function(){return _kameleoonData.UserAgent}}),Object.defineProperty(exports,"VISITOR_CODE_LENGTH",{enumerable:!0,get:function(){return _constants.VISITOR_CODE_LENGTH}}),Object.defineProperty(exports,"VariableType",{enumerable:!0,get:function(){return _types.VariableType}}),Object.defineProperty(exports,"VisitorCodeManager",{enumerable:!0,get:function(){return _visitorCodeManager.VisitorCodeManager}}),Object.defineProperty(exports,"VisitorDataFiltersType",{enumerable:!0,get:function(){return _utilities.VisitorDataFiltersType}});var _tsRes=require("ts-res"),_kameleoonClient=require("./kameleoonClient"),_kameleoonClientInterface=require("./kameleoonClientInterface"),_kameleoonUtils=require("./kameleoonUtils"),_kameleoonError=require("./kameleoonError"),_utilities=require("./utilities"),_storage=require("./storage"),_visitorCodeManager=require("./visitorCodeManager"),_constants=require("./constants"),_clientConfiguration=require("./clientConfiguration"),_types=require("./types"),_kameleoonData=require("./kameleoonData"),_eventSource=require("./eventSource"),_requester=require("./requester");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function(){return _kameleoonData.ApplicationVersion}}),Object.defineProperty(exports,"ApplicationVersionDataType",{enumerable:!0,get:function(){return _kameleoonData.ApplicationVersionDataType}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function(){return _kameleoonData.Browser}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function(){return _kameleoonData.BrowserType}}),Object.defineProperty(exports,"ConfigurationDataType",{enumerable:!0,get:function(){return _clientConfiguration.ConfigurationDataType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function(){return _kameleoonData.Conversion}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function(){return _kameleoonData.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function(){return _kameleoonData.Cookie}}),Object.defineProperty(exports,"CookieType",{enumerable:!0,get:function(){return _kameleoonData.CookieType}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function(){return _kameleoonData.CustomData}}),Object.defineProperty(exports,"DEFAULT_CLEANUP_INTERVAL",{enumerable:!0,get:function(){return _kameleoonData.DEFAULT_CLEANUP_INTERVAL}}),Object.defineProperty(exports,"DEFAULT_REQUEST_TIMEOUT",{enumerable:!0,get:function(){return _requester.DEFAULT_REQUEST_TIMEOUT}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function(){return _kameleoonData.Device}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function(){return _kameleoonData.DeviceType}}),Object.defineProperty(exports,"Environment",{enumerable:!0,get:function(){return _types.Environment}}),Object.defineProperty(exports,"Err",{enumerable:!0,get:function(){return _tsRes.Err}}),Object.defineProperty(exports,"EventSourceOpenParametersType",{enumerable:!0,get:function(){return _eventSource.EventSourceOpenParametersType}}),Object.defineProperty(exports,"ExternalPackageInfoType",{enumerable:!0,get:function(){return _types.ExternalPackageInfoType}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureFlagVariableType",{enumerable:!0,get:function(){return _types.FeatureFlagVariableType}}),Object.defineProperty(exports,"FeatureFlagVariationsType",{enumerable:!0,get:function(){return _storage.FeatureFlagVariationsType}}),Object.defineProperty(exports,"FeatureVariableResultType",{enumerable:!0,get:function(){return _types.FeatureVariableResultType}}),Object.defineProperty(exports,"GeolocationData",{enumerable:!0,get:function(){return _kameleoonData.GeolocationData}}),Object.defineProperty(exports,"GeolocationInfoType",{enumerable:!0,get:function(){return _kameleoonData.GeolocationInfoType}}),Object.defineProperty(exports,"GetFeatureFlagVariableParamsType",{enumerable:!0,get:function(){return _types.GetFeatureFlagVariableParamsType}}),Object.defineProperty(exports,"GetVisitorWarehouseAudienceParamsType",{enumerable:!0,get:function(){return _types.GetVisitorWarehouseAudienceParamsType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function(){return _requester.Header}}),Object.defineProperty(exports,"HeadersType",{enumerable:!0,get:function(){return _requester.HeadersType}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function(){return _requester.HttpMethod}}),Object.defineProperty(exports,"IExternalEventSource",{enumerable:!0,get:function(){return _eventSource.IExternalEventSource}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function(){return _requester.IExternalRequestDispatcher}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function(){return _storage.IExternalStorage}}),Object.defineProperty(exports,"IKameleoonCore",{enumerable:!0,get:function(){return _kameleoonClientInterface.IKameleoonClient}}),Object.defineProperty(exports,"IVisitorCodeManager",{enumerable:!0,get:function(){return _visitorCodeManager.IVisitorCodeManager}}),Object.defineProperty(exports,"InternalSDKConfigurationType",{enumerable:!0,get:function(){return _types.InternalSDKConfigurationType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function(){return _clientConfiguration.JSONType}}),Object.defineProperty(exports,"KameleoonCore",{enumerable:!0,get:function(){return _kameleoonClient.KameleoonClient}}),Object.defineProperty(exports,"KameleoonCoreUtils",{enumerable:!0,get:function(){return _kameleoonUtils.KameleoonUtils}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function(){return _kameleoonData.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function(){return _kameleoonData.KameleoonDataType}}),Object.defineProperty(exports,"KameleoonError",{enumerable:!0,get:function(){return _kameleoonError.KameleoonError}}),Object.defineProperty(exports,"KameleoonException",{enumerable:!0,get:function(){return _kameleoonError.KameleoonException}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function(){return _storage.KameleoonStorageKey}}),Object.defineProperty(exports,"KameleoonVariationType",{enumerable:!0,get:function(){return _types.KameleoonVariationType}}),Object.defineProperty(exports,"Milliseconds",{enumerable:!0,get:function(){return _types.Milliseconds}}),Object.defineProperty(exports,"NUMBER_OF_RETRIES",{enumerable:!0,get:function(){return _requester.NUMBER_OF_RETRIES}}),Object.defineProperty(exports,"Ok",{enumerable:!0,get:function(){return _tsRes.Ok}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function(){return _kameleoonData.OperatingSystem}}),Object.defineProperty(exports,"OperatingSystemType",{enumerable:!0,get:function(){return _kameleoonData.OperatingSystemType}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function(){return _kameleoonData.PageView}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function(){return _kameleoonData.PageViewParametersType}}),Object.defineProperty(exports,"RETRIES_DELAY",{enumerable:!0,get:function(){return _requester.RETRIES_DELAY}}),Object.defineProperty(exports,"RemoteVisitorDataParamsType",{enumerable:!0,get:function(){return _types.RemoteVisitorDataParamsType}}),Object.defineProperty(exports,"Result",{enumerable:!0,get:function(){return _tsRes.Result}}),Object.defineProperty(exports,"SDKConfigurationType",{enumerable:!0,get:function(){return _types.SDKConfigurationType}}),Object.defineProperty(exports,"SDKCoreParameters",{enumerable:!0,get:function(){return _types.SDKCoreParameters}}),Object.defineProperty(exports,"SdkLanguageType",{enumerable:!0,get:function(){return _constants.SdkLanguageType}}),Object.defineProperty(exports,"SetDataCallbackParametersType",{enumerable:!0,get:function(){return _types.SetDataCallbackParametersType}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function(){return _storage.StorageDataType}}),Object.defineProperty(exports,"TrackConversionParamsType",{enumerable:!0,get:function(){return _types.TrackConversionParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function(){return _requester.TrackParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function(){return _kameleoonData.UserAgent}}),Object.defineProperty(exports,"VISITOR_CODE_LENGTH",{enumerable:!0,get:function(){return _constants.VISITOR_CODE_LENGTH}}),Object.defineProperty(exports,"VariableType",{enumerable:!0,get:function(){return _types.VariableType}}),Object.defineProperty(exports,"VisitorCodeManager",{enumerable:!0,get:function(){return _visitorCodeManager.VisitorCodeManager}}),Object.defineProperty(exports,"VisitorDataFiltersType",{enumerable:!0,get:function(){return _utilities.VisitorDataFiltersType}});var _tsRes=require("ts-res"),_kameleoonClient=require("./kameleoonClient"),_kameleoonClientInterface=require("./kameleoonClientInterface"),_kameleoonUtils=require("./kameleoonUtils"),_kameleoonError=require("./kameleoonError"),_utilities=require("./utilities"),_storage=require("./storage"),_visitorCodeManager=require("./visitorCodeManager"),_constants=require("./constants"),_clientConfiguration=require("./clientConfiguration"),_types=require("./types"),_kameleoonData=require("./kameleoonData"),_eventSource=require("./eventSource"),_requester=require("./requester");
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { Ok, Result, Err } from 'ts-res';\nexport { KameleoonClient as KameleoonCore } from './kameleoonClient';\nexport { IKameleoonClient as IKameleoonCore } from './kameleoonClientInterface';\nexport { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';\nexport { KameleoonException, KameleoonError } from './kameleoonError';\nexport { VisitorDataFiltersType } from './utilities';\nexport {\n FeatureFlagVariationsType,\n KameleoonStorageKey,\n StorageDataType,\n IExternalStorage,\n} from './storage';\nexport { VisitorCodeManager, IVisitorCodeManager } from './visitorCodeManager';\nexport { VISITOR_CODE_LENGTH, SdkLanguageType } from './constants';\nexport { JSONType, ConfigurationDataType } from './clientConfiguration';\nexport {\n Environment,\n VariableType,\n FeatureFlagType,\n SDKCoreParameters,\n SDKConfigurationType,\n ExternalPackageInfoType,\n FeatureFlagVariableType,\n TrackConversionParamsType,\n FeatureVariableResultType,\n RemoteVisitorDataParamsType,\n InternalSDKConfigurationType,\n SetDataCallbackParametersType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n Milliseconds,\n} from './types';\nexport { DEFAULT_CLEANUP_INTERVAL } from './kameleoonData';\nexport {\n ApplicationVersion,\n CustomData,\n Conversion,\n Device,\n Cookie,\n Browser,\n UserAgent,\n DeviceType,\n CookieType,\n GeolocationData,\n GeolocationInfoType,\n OperatingSystemType,\n OperatingSystem,\n BrowserType,\n PageView,\n KameleoonData,\n KameleoonDataType,\n PageViewParametersType,\n ConversionParametersType,\n ApplicationVersionDataType,\n} from './kameleoonData';\nexport {\n IExternalEventSource,\n EventSourceOpenParametersType,\n} from './eventSource';\nexport {\n Header,\n HeadersType,\n HttpMethod,\n TrackParametersType,\n IExternalRequestDispatcher,\n DEFAULT_REQUEST_TIMEOUT,\n NUMBER_OF_RETRIES,\n RETRIES_DELAY,\n} from './requester';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { Ok, Result, Err } from 'ts-res';\nexport { KameleoonClient as KameleoonCore } from './kameleoonClient';\nexport { IKameleoonClient as IKameleoonCore } from './kameleoonClientInterface';\nexport { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';\nexport { KameleoonException, KameleoonError } from './kameleoonError';\nexport { VisitorDataFiltersType } from './utilities';\nexport {\n FeatureFlagVariationsType,\n KameleoonStorageKey,\n StorageDataType,\n IExternalStorage,\n} from './storage';\nexport { VisitorCodeManager, IVisitorCodeManager } from './visitorCodeManager';\nexport { VISITOR_CODE_LENGTH, SdkLanguageType } from './constants';\nexport { JSONType, ConfigurationDataType } from './clientConfiguration';\nexport {\n Environment,\n VariableType,\n FeatureFlagType,\n SDKCoreParameters,\n SDKConfigurationType,\n KameleoonVariationType,\n ExternalPackageInfoType,\n FeatureFlagVariableType,\n TrackConversionParamsType,\n FeatureVariableResultType,\n RemoteVisitorDataParamsType,\n InternalSDKConfigurationType,\n SetDataCallbackParametersType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n Milliseconds,\n} from './types';\nexport { DEFAULT_CLEANUP_INTERVAL } from './kameleoonData';\nexport {\n ApplicationVersion,\n CustomData,\n Conversion,\n Device,\n Cookie,\n Browser,\n UserAgent,\n DeviceType,\n CookieType,\n GeolocationData,\n GeolocationInfoType,\n OperatingSystemType,\n OperatingSystem,\n BrowserType,\n PageView,\n KameleoonData,\n KameleoonDataType,\n PageViewParametersType,\n ConversionParametersType,\n ApplicationVersionDataType,\n} from './kameleoonData';\nexport {\n IExternalEventSource,\n EventSourceOpenParametersType,\n} from './eventSource';\nexport {\n Header,\n HeadersType,\n HttpMethod,\n TrackParametersType,\n IExternalRequestDispatcher,\n DEFAULT_REQUEST_TIMEOUT,\n NUMBER_OF_RETRIES,\n RETRIES_DELAY,\n} from './requester';\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import { JSONType } from './clientConfiguration';
2
2
  import { CustomData, KameleoonDataType } from './kameleoonData';
3
- import { TrackConversionParamsType, FeatureFlagType, GetFeatureFlagVariableParamsType, FeatureVariableResultType, SDKCoreParameters, RemoteVisitorDataParamsType, GetVisitorWarehouseAudienceParamsType, SetUserConsentParametersType, FeatureFlagVariableType } from './types';
3
+ import { TrackConversionParamsType, FeatureFlagType, GetFeatureFlagVariableParamsType, FeatureVariableResultType, SDKCoreParameters, RemoteVisitorDataParamsType, GetVisitorWarehouseAudienceParamsType, SetUserConsentParametersType, FeatureFlagVariableType, KameleoonVariationType } from './types';
4
4
  import { IKameleoonClient } from './kameleoonClientInterface';
5
5
  /**
6
6
  * @class
@@ -26,11 +26,12 @@ export declare class KameleoonClient implements IKameleoonClient {
26
26
  constructor({ siteCode, configuration, internalConfiguration, }: SDKCoreParameters);
27
27
  initialize(useCache?: boolean): Promise<boolean>;
28
28
  addData(visitorCode: string, ...data: KameleoonDataType[]): void;
29
- getRemoteVisitorData({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]>;
29
+ getRemoteVisitorData({ visitorCode, shouldAddData, filters, isUniqueIdentifier, }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]>;
30
30
  trackConversion({ visitorCode, goalId, revenue, isUniqueIdentifier, }: TrackConversionParamsType): void;
31
31
  flush(visitorCode?: string, isUniqueIdentifier?: boolean): void;
32
32
  getFeatureFlags(): FeatureFlagType[];
33
33
  getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[];
34
+ getActiveFeatureFlags(visitorCode: string): Map<string, KameleoonVariationType>;
34
35
  getFeatureFlagVariationKey(visitorCode: string, featureKey: string): string;
35
36
  getFeatureFlagVariable({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType): FeatureFlagVariableType;
36
37
  getFeatureFlagVariables(visitorCode: string, featureKey: string): FeatureVariableResultType[];
@@ -39,7 +40,10 @@ export declare class KameleoonClient implements IKameleoonClient {
39
40
  getVisitorWarehouseAudience({ visitorCode, customDataIndex, warehouseKey, }: GetVisitorWarehouseAudienceParamsType): Promise<CustomData | null>;
40
41
  onConfigurationUpdate(callback: () => void): void;
41
42
  getEngineTrackingCode(visitorCode: string): string;
43
+ isInitialized(): boolean;
42
44
  protected setUserConsent({ visitorCode, consent, setData, }: SetUserConsentParametersType): void;
43
45
  private _isConsentProvided;
44
- private _getFeatureFlagVariation;
46
+ private _getFeatureVariables;
47
+ private _getActiveFeatureVariations;
48
+ private _getFeatureVariation;
45
49
  }
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _tsRes=require("ts-res"),_cacheManager=require("./cacheManager"),_clientConfiguration=require("./clientConfiguration"),_clientSettings=require("./clientSettings"),_constants=require("./constants"),_kameleoonData=require("./kameleoonData"),_kameleoonError=require("./kameleoonError"),_requester=require("./requester"),_storage=require("./storage"),_types=require("./types"),_utilities=require("./utilities"),_variationConfiguration=require("./variationConfiguration"),_eventSource=require("./eventSource"),_visitorCodeManager=require("./visitorCodeManager");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||!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 KameleoonClient{constructor(a){let{siteCode:b,configuration:c,internalConfiguration:d}=a;_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"clientConfiguration",void 0),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"consentDataStorage",void 0),_defineProperty(this,"trackingCache",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"externalPackageInfo",void 0),_defineProperty(this,"isOfflineModeOn",void 0),_defineProperty(this,"initialized",!1),_defineProperty(this,"environment",void 0),_defineProperty(this,"visitorCodeManager",void 0);const{settings:e}=new _clientSettings.ClientSettings(b,c);this.environment=e.environment;const{externalStorage:f,externalEventSource:g,externalPackageInfo:h,externalVisitorCodeManager:i,externalRequestDispatcher:j,externalClientConfiguration:k}=d,l=new _cacheManager.CacheManager(_constants.CACHE_CLEANUP_TIMEOUT),m=new _storage.DataStorage(f,_storage.KameleoonStorageKey.ClientData),n=new _storage.DataStorage(f,_storage.KameleoonStorageKey.TargetingData),o=new _storage.DataStorage(f,_storage.KameleoonStorageKey.VariationData),p=new _storage.DataStorage(f,_storage.KameleoonStorageKey.OfflineTracking),q=new _storage.DataStorage(f,_storage.KameleoonStorageKey.ConsentData),r=new _kameleoonData.DataManager({storage:n,targetingCleanupInterval:null===c||void 0===c?void 0:c.targetingDataCleanupInterval}),s=new _eventSource.KameleoonEventSource(e.siteCode,g),t=new _requester.Requester({siteCode:b,environment:e.environment,packageInfo:h,requestDispatcher:j}),u=new _clientConfiguration.ClientConfiguration({settings:e,storage:m,dataManager:r,requester:t,externalClientConfiguration:k,offlineTrackingStorage:p,eventSource:s,externalVisitorCodeManager:i}),v=new _variationConfiguration.VariationConfiguration(o);this.variationConfiguration=v,this.requester=t,this.trackingCache=l,this.dataManager=r,this.clientConfiguration=u,this.externalPackageInfo=h,this.offlineTrackingStorage=p,this.consentDataStorage=q,this.visitorCodeManager=i}async initialize(a){const b=await this.clientConfiguration.initialize();return b.throw(),this.isOfflineModeOn=a,this.initialized=!0,b.ok}addData(a){if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];this.dataManager.addData(a,...c).throw()}async getRemoteVisitorData(a){let{visitorCode:b,shouldAddData:c=!0,filters:d=_constants.DEFAULT_VISITOR_DATA_FILTERS}=a;if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(b).throw();const{previousVisitAmount:e}=d;if("number"==typeof e&&(1>e||25<e))throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitAmount);const f=await this.requester.getVisitorData(b,d),g=f.throw(),{visitorData:h,visitsData:i}=_utilities.Utilities.parseVisitorData({data:g,filters:d,visitorCode:b,variationConfiguration:this.variationConfiguration});for(const d of h)(c||this.dataManager.isPersistentCustomData(d))&&this.addData(b,d);return i&&c&&this.addData(b,i),h}trackConversion(a){let{visitorCode:b,goalId:c,revenue:d,isUniqueIdentifier:e}=a;this.addData(b,new _kameleoonData.Conversion({goalId:c,revenue:d})),this.flush(b,e)}flush(a,b){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);if("string"==typeof a&&_utilities.Utilities.validateVisitorCode(a).throw(),a)return void _utilities.Utilities.trackData({visitorCode:a,isMappingIdentifier:b,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(a),offlineTrackingStorage:this.offlineTrackingStorage});if(!this.dataManager.unsentDataVisitors.length)return void _utilities.Utilities.sendOfflineTracking({requester:this.requester,storage:this.offlineTrackingStorage});for(const c of this.dataManager.unsentDataVisitors)_utilities.Utilities.trackData({visitorCode:c,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(c),offlineTrackingStorage:this.offlineTrackingStorage})}getFeatureFlags(){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.clientConfiguration.featureFlags.map(a=>{let{id:b,featureKey:c}=a;return{id:b,key:c}})}getVisitorFeatureFlags(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);const b=this.clientConfiguration.featureFlags,c=[],d=this.dataManager.storedTargetingData[a],e=this.dataManager.getVisitorIdentifier(a);for(const f of b){const b=this.variationConfiguration.getVariation({visitorCode:a,visitorIdentifier:e,targetingData:d,featureFlag:f,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw();if(b.variationKey!==_constants.OFF_VARIATION_KEY&&f.environmentEnabled){const{featureFlagId:a,featureKey:d}=b;c.push({id:a,key:d})}}return c}getFeatureFlagVariationKey(a,b){_utilities.Utilities.validateVisitorCode(a).throw();const{variationKey:c}=this._getFeatureFlagVariation(a,b).throw();return c}getFeatureFlagVariable(a){var b;let{visitorCode:c,featureKey:d,variableKey:e}=a;_utilities.Utilities.validateVisitorCode(c).throw();const{variationKey:f}=this._getFeatureFlagVariation(c,d).throw(),g=this.clientConfiguration.featureFlags,h=g.find(a=>a.featureKey===d);if(!h)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,d);const i=null===(b=h.variations.find(a=>a.key===f))||void 0===b?void 0:b.variables.find(a=>a.key===e);if(!i)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariableNotFound,e,c);const{type:j,value:k}=_utilities.Utilities.parseFeatureVariable(i).throw();return{type:j,value:k}}getFeatureFlagVariables(a,b){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(a).throw();const{variationKey:c}=this._getFeatureFlagVariation(a,b).throw(),d=this.clientConfiguration.featureFlags,e=d.find(a=>a.featureKey===b);if(!e)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b);const f=e.variations.find(a=>a.key===c);if(!f)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariationNotFound,c,a);const g=[];for(const c of f.variables){const a=_utilities.Utilities.parseFeatureVariable(c).throw();g.push(a)}return g}isFeatureFlagActive(a,b){try{const c=this.getFeatureFlagVariationKey(a,b);return c!==_constants.OFF_VARIATION_KEY}catch(a){if(a instanceof _kameleoonError.KameleoonError&&a.type===_kameleoonError.KameleoonException.FeatureFlagEnvironmentDisabled)return!1;throw a}}async getRemoteData(a){const b=await this.requester.getRemoteData(a);return b.throw()}async getVisitorWarehouseAudience(a){let{visitorCode:b,customDataIndex:c,warehouseKey:d}=a;_utilities.Utilities.validateVisitorCode(b).throw();const e=await this.getRemoteData(d||b);if(!e)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.RemoteData);if(!e[_constants.WAREHOUSE_AUDIENCE_KEY]||0===Object.keys(e[_constants.WAREHOUSE_AUDIENCE_KEY]).length)return null;const f=new _kameleoonData.CustomData(c,...Object.keys(e[_constants.WAREHOUSE_AUDIENCE_KEY]));return this.dataManager.addData(b,f),f}onConfigurationUpdate(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);this.clientConfiguration.onConfigurationUpdate(a)}getEngineTrackingCode(a){return _utilities.Utilities.validateVisitorCode(a).throw(),_utilities.Utilities.getTrackingCode(this.trackingCache,a)}setUserConsent(a){let{visitorCode:b,consent:c,setData:d}=a;_utilities.Utilities.validateVisitorCode(b).throw(),this.consentDataStorage.update({[b]:c}),c?d({visitorCode:b,key:_storage.KameleoonStorageKey.VisitorCode,maxAge:_visitorCodeManager.DEFAULT_MAX_AGE,path:_visitorCodeManager.PATH}):this.visitorCodeManager.consentRequired&&d({visitorCode:"",key:_storage.KameleoonStorageKey.VisitorCode,maxAge:_visitorCodeManager.ZERO_MAX_AGE,path:_visitorCodeManager.PATH})}_isConsentProvided(a){const{isConsentRequired:b}=this.clientConfiguration,c=this.consentDataStorage.read();return!b||c.ok&&c.data[a]}_getFeatureFlagVariation(a,b){if(!this.initialized)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));const c=this.clientConfiguration.featureFlags,d=c.find(a=>a.featureKey===b);if(!d)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b));if(!d.environmentEnabled)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagEnvironmentDisabled,d.featureKey,this.environment||_types.Environment.Production));const e=this.dataManager.storedTargetingData[a],f=this.dataManager.getVisitorIdentifier(a),g=this.variationConfiguration.getVariation({visitorCode:a,visitorIdentifier:f,featureFlag:d,targetingData:e,withAssignment:!0,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw(),{experimentId:h,variationId:i}=g;return"number"==typeof i&&"number"==typeof h&&_utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:h,variationId:i}),_utilities.Utilities.trackFeatureExperiment({visitorCode:a,requester:this.requester,featureFlagVariation:g,dataManager:this.dataManager,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(a),offlineTrackingStorage:this.offlineTrackingStorage,variationConfiguration:this.variationConfiguration}),(0,_tsRes.Ok)(g)}}exports.KameleoonClient=KameleoonClient;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _tsRes=require("ts-res"),_cacheManager=require("./cacheManager"),_clientConfiguration=require("./clientConfiguration"),_clientSettings=require("./clientSettings"),_constants=require("./constants"),_kameleoonData=require("./kameleoonData"),_kameleoonError=require("./kameleoonError"),_requester=require("./requester"),_storage=require("./storage"),_types=require("./types"),_utilities=require("./utilities"),_variationConfiguration=require("./variationConfiguration"),_eventSource=require("./eventSource"),_visitorCodeManager=require("./visitorCodeManager");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||!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 KameleoonClient{constructor(a){let{siteCode:b,configuration:c,internalConfiguration:d}=a;_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"clientConfiguration",void 0),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"consentDataStorage",void 0),_defineProperty(this,"trackingCache",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"externalPackageInfo",void 0),_defineProperty(this,"isOfflineModeOn",void 0),_defineProperty(this,"initialized",!1),_defineProperty(this,"environment",void 0),_defineProperty(this,"visitorCodeManager",void 0);const{settings:e}=new _clientSettings.ClientSettings(b,c);this.environment=e.environment;const{externalStorage:f,externalEventSource:g,externalPackageInfo:h,externalVisitorCodeManager:i,externalRequestDispatcher:j,externalClientConfiguration:k}=d,l=new _cacheManager.CacheManager(_constants.CACHE_CLEANUP_TIMEOUT),m=new _storage.DataStorage(f,_storage.KameleoonStorageKey.ClientData),n=new _storage.DataStorage(f,_storage.KameleoonStorageKey.TargetingData),o=new _storage.DataStorage(f,_storage.KameleoonStorageKey.VariationData),p=new _storage.DataStorage(f,_storage.KameleoonStorageKey.OfflineTracking),q=new _storage.DataStorage(f,_storage.KameleoonStorageKey.ConsentData),r=new _kameleoonData.DataManager({storage:n,targetingCleanupInterval:null===c||void 0===c?void 0:c.targetingDataCleanupInterval}),s=new _eventSource.KameleoonEventSource(e.siteCode,g),t=new _requester.Requester({siteCode:b,environment:e.environment,packageInfo:h,requestDispatcher:j}),u=new _clientConfiguration.ClientConfiguration({settings:e,storage:m,dataManager:r,requester:t,externalClientConfiguration:k,offlineTrackingStorage:p,eventSource:s,externalVisitorCodeManager:i}),v=new _variationConfiguration.VariationConfiguration(o);this.variationConfiguration=v,this.requester=t,this.trackingCache=l,this.dataManager=r,this.clientConfiguration=u,this.externalPackageInfo=h,this.offlineTrackingStorage=p,this.consentDataStorage=q,this.visitorCodeManager=i}async initialize(a){const b=await this.clientConfiguration.initialize();return b.throw(),this.isOfflineModeOn=a,this.initialized=!0,b.ok}addData(a){if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];this.dataManager.addData(a,...c).throw()}async getRemoteVisitorData(a){let{visitorCode:b,shouldAddData:c=!0,filters:d=_constants.DEFAULT_VISITOR_DATA_FILTERS,isUniqueIdentifier:e=!1}=a;if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(b).throw();const{previousVisitAmount:f}=d;if("number"==typeof f&&(1>f||25<f))throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitAmount);const g=await this.requester.getVisitorData({visitorCode:b,filters:d,isMappingIdentifier:e}),h=g.throw(),{visitorData:i,storageVisitorData:j,visitsData:k}=_utilities.Utilities.parseVisitorData({data:h,filters:d,visitorCode:b,dataManager:this.dataManager,variationConfiguration:this.variationConfiguration});for(const d of j)(c||this.dataManager.isPersistentCustomData(d))&&this.addData(b,d);return k&&c&&this.addData(b,k),i}trackConversion(a){let{visitorCode:b,goalId:c,revenue:d,isUniqueIdentifier:e}=a;this.addData(b,new _kameleoonData.Conversion({goalId:c,revenue:d})),this.flush(b,e)}flush(a,b){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);if("string"==typeof a&&_utilities.Utilities.validateVisitorCode(a).throw(),a){let c=!1;if(b){const b=this.dataManager.getLinkedVisitor(a),d=this.dataManager.identifierCustomDataIndex;b||"number"!=typeof d?c=!0:this.dataManager.addData(a,new _kameleoonData.CustomData(d,a))}return void _utilities.Utilities.trackData({visitorCode:a,isMappingIdentifier:c,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(a),offlineTrackingStorage:this.offlineTrackingStorage})}if(!this.dataManager.unsentDataVisitors.length)return void _utilities.Utilities.sendOfflineTracking({requester:this.requester,storage:this.offlineTrackingStorage});for(const c of this.dataManager.unsentDataVisitors)_utilities.Utilities.trackData({visitorCode:c,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(c),offlineTrackingStorage:this.offlineTrackingStorage})}getFeatureFlags(){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);const a=this.clientConfiguration.featureFlags,b=[];return a.forEach(a=>{let{id:c,featureKey:d}=a;b.push({id:c,key:d})}),b}getVisitorFeatureFlags(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);const b=this._getActiveFeatureVariations(a),c=[];return b.forEach(a=>{let{featureFlagId:b,featureKey:d}=a;c.push({id:b,key:d})}),c}getActiveFeatureFlags(a){const b=this._getActiveFeatureVariations(a),c=new Map;return b.forEach(b=>{const{variationKey:d,featureKey:e,variationId:f,experimentId:g}=b;let h=[];null!==f&&null!==g&&(h=this._getFeatureVariables({visitorCode:a,featureKey:e,variationKey:d}));const i=h.map(a=>_utilities.Utilities.parseFeatureVariable(a).throw());c.set(b.featureKey,{key:d,id:f,experimentId:g,variables:i})}),c}getFeatureFlagVariationKey(a,b){_utilities.Utilities.validateVisitorCode(a).throw();const{variationKey:c}=this._getFeatureVariation(a,b).throw();return c}getFeatureFlagVariable(a){let{visitorCode:b,featureKey:c,variableKey:d}=a;_utilities.Utilities.validateVisitorCode(b).throw();const{variationKey:e}=this._getFeatureVariation(b,c).throw(),f=this._getFeatureVariables({visitorCode:b,featureKey:c,variationKey:e}),g=f.find(a=>a.key===d);if(!g)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariableNotFound,d,b);const{type:h,value:i}=_utilities.Utilities.parseFeatureVariable(g).throw();return{type:h,value:i}}getFeatureFlagVariables(a,b){_utilities.Utilities.validateVisitorCode(a).throw();const{variationKey:c}=this._getFeatureVariation(a,b).throw(),d=this._getFeatureVariables({visitorCode:a,featureKey:b,variationKey:c}),e=[];for(const c of d){const a=_utilities.Utilities.parseFeatureVariable(c).throw();e.push(a)}return e}isFeatureFlagActive(a,b){try{const c=this.getFeatureFlagVariationKey(a,b);return c!==_constants.OFF_VARIATION_KEY}catch(a){if(a instanceof _kameleoonError.KameleoonError&&a.type===_kameleoonError.KameleoonException.FeatureFlagEnvironmentDisabled)return!1;throw a}}async getRemoteData(a){const b=await this.requester.getRemoteData(a);return b.throw()}async getVisitorWarehouseAudience(a){let{visitorCode:b,customDataIndex:c,warehouseKey:d}=a;_utilities.Utilities.validateVisitorCode(b).throw();const e=await this.getRemoteData(d||b);if(!e)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.RemoteData);if(!e[_constants.WAREHOUSE_AUDIENCE_KEY]||0===Object.keys(e[_constants.WAREHOUSE_AUDIENCE_KEY]).length)return null;const f=new _kameleoonData.CustomData(c,...Object.keys(e[_constants.WAREHOUSE_AUDIENCE_KEY]));return this.dataManager.addData(b,f),f}onConfigurationUpdate(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);this.clientConfiguration.onConfigurationUpdate(a)}getEngineTrackingCode(a){return _utilities.Utilities.validateVisitorCode(a).throw(),_utilities.Utilities.getTrackingCode(this.trackingCache,a)}isInitialized(){return this.initialized}setUserConsent(a){let{visitorCode:b,consent:c,setData:d}=a;_utilities.Utilities.validateVisitorCode(b).throw(),this.consentDataStorage.update({[b]:c}),c?d({visitorCode:b,key:_storage.KameleoonStorageKey.VisitorCode,maxAge:_visitorCodeManager.DEFAULT_MAX_AGE,path:_visitorCodeManager.PATH}):this.visitorCodeManager.consentRequired&&d({visitorCode:"",key:_storage.KameleoonStorageKey.VisitorCode,maxAge:_visitorCodeManager.ZERO_MAX_AGE,path:_visitorCodeManager.PATH})}_isConsentProvided(a){const{isConsentRequired:b}=this.clientConfiguration,c=this.consentDataStorage.read();return!b||c.ok&&c.data[a]}_getFeatureVariables(a){let{visitorCode:b,featureKey:c,variationKey:d}=a;const e=this.clientConfiguration.featureFlags,f=e.get(c);if(!f)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,c);const g=f.variations.find(a=>a.key===d);if(!g)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariationNotFound,d,b);return g.variables}_getActiveFeatureVariations(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);const b=this.clientConfiguration.featureFlags,c=[],d=this.dataManager.getTargetingData(a),e=this.dataManager.getVisitorIdentifier(a);for(const f of b.values()){if(!f.environmentEnabled)continue;const b=this.variationConfiguration.getVariation({visitorCode:a,visitorIdentifier:e,targetingData:d,featureFlag:f,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw();b.variationKey!==_constants.OFF_VARIATION_KEY&&c.push(b)}return c}_getFeatureVariation(a,b){if(!this.initialized)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));const c=this.clientConfiguration.featureFlags,d=c.get(b);if(!d)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b));if(!d.environmentEnabled)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagEnvironmentDisabled,d.featureKey,this.environment||_types.Environment.Production));const e=this.dataManager.getTargetingData(a),f=this.dataManager.getVisitorIdentifier(a),g=this.variationConfiguration.getVariation({visitorCode:a,visitorIdentifier:f,featureFlag:d,targetingData:e,withAssignment:!0,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw(),{experimentId:h,variationId:i}=g;return"number"==typeof i&&"number"==typeof h&&_utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:h,variationId:i}),_utilities.Utilities.trackFeatureExperiment({visitorCode:a,requester:this.requester,featureFlagVariation:g,dataManager:this.dataManager,isOfflineModeOn:this.isOfflineModeOn,isConsentProvided:this._isConsentProvided(a),offlineTrackingStorage:this.offlineTrackingStorage,variationConfiguration:this.variationConfiguration}),(0,_tsRes.Ok)(g)}}exports.KameleoonClient=KameleoonClient;
2
2
  //# sourceMappingURL=kameleoonClient.js.map