@kameleoon/javascript-sdk-core 4.1.0 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
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
+
3
13
  ## 4.1.0 (2024-04-19)
4
14
 
5
15
  ### Features
@@ -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,W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IAAI,CAAClD,WAAW,CAACmD,KAAK,CAAC,CAAC,CAExB,KAAM,CAAAhB,CAAM,CAAG,IAAI,CAACiB,iBAAiB,CAAC,CAAC,CAEvC,GAAI,CAACjB,CAAM,CAAC1E,EAAE,CACZ,MAAO,CAAA0E,CAAM,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,CA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,CAC5B,KAAM,KAAI,CAACZ,UAAU,CAAC,CAAC,EAMzB,KAAM,CAAA4G,CAAe,CACnB,IAAI,CAAChD,iBAAiB,EAAI,CAAC,IAAI,CAACI,0BAA0B,CAG5D,MAFA,KAAI,CAACjE,kBAAkB,CAAC6G,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/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
@@ -31,6 +31,7 @@ export declare class KameleoonClient implements IKameleoonClient {
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[];
@@ -42,5 +43,7 @@ export declare class KameleoonClient implements IKameleoonClient {
42
43
  isInitialized(): boolean;
43
44
  protected setUserConsent({ visitorCode, consent, setData, }: SetUserConsentParametersType): void;
44
45
  private _isConsentProvided;
45
- private _getFeatureFlagVariation;
46
+ private _getFeatureVariables;
47
+ private _getActiveFeatureVariations;
48
+ private _getFeatureVariation;
46
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,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);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.getTargetingData(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)}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]}_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.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;
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
@@ -1 +1 @@
1
- {"version":3,"file":"kameleoonClient.js","names":["KameleoonClient","constructor","a","siteCode","configuration","internalConfiguration","_defineProperty","settings","clientSettings","ClientSettings","environment","externalStorage","externalEventSource","externalPackageInfo","externalVisitorCodeManager","externalRequestDispatcher","externalClientConfiguration","trackingCache","CacheManager","CACHE_CLEANUP_TIMEOUT","clientDataStorage","DataStorage","KameleoonStorageKey","ClientData","targetingDataStorage","TargetingData","variationDataStorage","VariationData","offlineTrackingStorage","OfflineTracking","consentDataStorage","ConsentData","dataManager","DataManager","storage","targetingCleanupInterval","targetingDataCleanupInterval","eventSource","KameleoonEventSource","requester","Requester","packageInfo","requestDispatcher","clientConfiguration","ClientConfiguration","variationConfiguration","VariationConfiguration","visitorCodeManager","initialize","useCache","result","throw","isOfflineModeOn","initialized","ok","addData","visitorCode","Utilities","validateVisitorCode","KameleoonError","KameleoonException","Initialization","b","arguments","length","data","Array","d","getRemoteVisitorData","shouldAddData","filters","DEFAULT_VISITOR_DATA_FILTERS","isUniqueIdentifier","previousVisitAmount","VisitAmount","getVisitorData","isMappingIdentifier","visitorData","storageVisitorData","visitsData","parseVisitorData","dataItem","isPersistentCustomData","trackConversion","goalId","revenue","Conversion","flush","linkedVisitor","getLinkedVisitor","index","identifierCustomDataIndex","CustomData","trackData","isConsentProvided","_isConsentProvided","unsentDataVisitors","sendOfflineTracking","visitorCodeKey","getFeatureFlags","featureFlags","map","id","featureKey","key","getVisitorFeatureFlags","resultFeatureFlags","targetingData","getTargetingData","visitorIdentifier","getVisitorIdentifier","featureFlag","variationData","getVariation","variationKey","OFF_VARIATION_KEY","environmentEnabled","featureFlagId","push","getFeatureFlagVariationKey","_getFeatureFlagVariation","getFeatureFlagVariable","variableKey","find","item","FeatureFlagConfigurationNotFound","variable","variations","variables","FeatureFlagVariableNotFound","type","value","parseFeatureVariable","getFeatureFlagVariables","variation","FeatureFlagVariationNotFound","parsedVariable","isFeatureFlagActive","err","FeatureFlagEnvironmentDisabled","getRemoteData","remoteData","getVisitorWarehouseAudience","customDataIndex","warehouseKey","RemoteData","WAREHOUSE_AUDIENCE_KEY","Object","keys","customData","onConfigurationUpdate","callback","getEngineTrackingCode","getTrackingCode","isInitialized","setUserConsent","consent","setData","update","VisitorCode","maxAge","DEFAULT_MAX_AGE","path","PATH","consentRequired","ZERO_MAX_AGE","isConsentRequired","consentDataResult","read","Err","Environment","Production","withAssignment","experimentId","variationId","updateCache","cacheManager","trackFeatureExperiment","featureFlagVariation","Ok","exports"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CacheManager } from './cacheManager';\nimport { ClientConfiguration, JSONType } from './clientConfiguration';\nimport { ClientSettings } from './clientSettings';\nimport {\n CACHE_CLEANUP_TIMEOUT,\n DEFAULT_VISITOR_DATA_FILTERS,\n OFF_VARIATION_KEY,\n} from './constants';\nimport {\n Conversion,\n CustomData,\n DataManager,\n KameleoonDataType,\n} from './kameleoonData';\nimport { WAREHOUSE_AUDIENCE_KEY } from './constants';\nimport { KameleoonError, KameleoonException } from './kameleoonError';\nimport { Requester } from './requester';\nimport {\n ClientDataType,\n KameleoonStorageKey,\n VariationDataType,\n DataStorage,\n ConsentDataType,\n IStorage,\n OfflineTracking,\n} from './storage';\nimport {\n TrackConversionParamsType,\n FeatureFlagType,\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n SDKCoreParameters,\n TrackingCacheItemType,\n ExternalPackageInfoType,\n RemoteVisitorDataParamsType,\n GetVisitorWarehouseAudienceParamsType,\n Environment,\n SetUserConsentParametersType,\n FeatureFlagVariableType,\n} from './types';\nimport { IVisitorCodeManager } from './visitorCodeManager';\nimport { Utilities } from './utilities';\nimport {\n FeatureFlagVariationType,\n VariationConfiguration,\n} from './variationConfiguration';\nimport { TargetingDataType } from './targeting';\nimport { KameleoonEventSource } from './eventSource';\nimport { IKameleoonClient } from './kameleoonClientInterface';\nimport { DEFAULT_MAX_AGE, PATH, ZERO_MAX_AGE } from './visitorCodeManager';\n\n/**\n * @class\n * KameleoonClient - a class for creating kameleoon client instance\n * for communicating with Kameleoon JavaScript SDK Core, when new instance is created\n */\nexport class KameleoonClient implements IKameleoonClient {\n private variationConfiguration: VariationConfiguration;\n private clientConfiguration: ClientConfiguration;\n private dataManager: DataManager;\n private offlineTrackingStorage: IStorage<OfflineTracking>;\n private consentDataStorage: IStorage<ConsentDataType>;\n private trackingCache: CacheManager<TrackingCacheItemType>;\n private requester: Requester;\n private externalPackageInfo: ExternalPackageInfoType;\n private isOfflineModeOn?: boolean;\n private initialized: boolean = false;\n private environment?: Environment;\n private visitorCodeManager: IVisitorCodeManager;\n\n /**\n * @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core\n */\n constructor({\n siteCode,\n configuration,\n internalConfiguration,\n }: SDKCoreParameters) {\n const { settings: clientSettings } = new ClientSettings(\n siteCode,\n configuration,\n );\n this.environment = clientSettings.environment;\n const {\n externalStorage,\n externalEventSource,\n externalPackageInfo,\n externalVisitorCodeManager,\n externalRequestDispatcher,\n externalClientConfiguration,\n } = internalConfiguration;\n const trackingCache = new CacheManager<TrackingCacheItemType>(\n CACHE_CLEANUP_TIMEOUT,\n );\n\n const clientDataStorage = new DataStorage<ClientDataType>(\n externalStorage,\n KameleoonStorageKey.ClientData,\n );\n const targetingDataStorage = new DataStorage<TargetingDataType>(\n externalStorage,\n KameleoonStorageKey.TargetingData,\n );\n const variationDataStorage = new DataStorage<VariationDataType>(\n externalStorage,\n KameleoonStorageKey.VariationData,\n );\n const offlineTrackingStorage = new DataStorage<OfflineTracking>(\n externalStorage,\n KameleoonStorageKey.OfflineTracking,\n );\n const consentDataStorage = new DataStorage<ConsentDataType>(\n externalStorage,\n KameleoonStorageKey.ConsentData,\n );\n\n const dataManager = new DataManager({\n storage: targetingDataStorage,\n targetingCleanupInterval: configuration?.targetingDataCleanupInterval,\n });\n\n const eventSource = new KameleoonEventSource(\n clientSettings.siteCode,\n externalEventSource,\n );\n\n const requester = new Requester({\n siteCode,\n environment: clientSettings.environment,\n packageInfo: externalPackageInfo,\n requestDispatcher: externalRequestDispatcher,\n });\n\n const clientConfiguration = new ClientConfiguration({\n settings: clientSettings,\n storage: clientDataStorage,\n dataManager,\n requester,\n externalClientConfiguration,\n offlineTrackingStorage,\n eventSource,\n externalVisitorCodeManager,\n });\n\n const variationConfiguration = new VariationConfiguration(\n variationDataStorage,\n );\n\n this.variationConfiguration = variationConfiguration;\n this.requester = requester;\n this.trackingCache = trackingCache;\n this.dataManager = dataManager;\n this.clientConfiguration = clientConfiguration;\n this.externalPackageInfo = externalPackageInfo;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.consentDataStorage = consentDataStorage;\n this.visitorCodeManager = externalVisitorCodeManager;\n }\n\n public async initialize(useCache?: boolean): Promise<boolean> {\n const result = await this.clientConfiguration.initialize();\n result.throw();\n\n this.isOfflineModeOn = useCache;\n this.initialized = true;\n\n return result.ok;\n }\n\n public addData(visitorCode: string, ...data: KameleoonDataType[]): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.dataManager.addData(visitorCode, ...data).throw();\n }\n\n public async getRemoteVisitorData({\n visitorCode,\n shouldAddData = true,\n filters = DEFAULT_VISITOR_DATA_FILTERS,\n isUniqueIdentifier = false,\n }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]> {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { previousVisitAmount } = filters;\n\n if (\n typeof previousVisitAmount === 'number' &&\n (previousVisitAmount < 1 || previousVisitAmount > 25)\n ) {\n throw new KameleoonError(KameleoonException.VisitAmount);\n }\n\n const result = await this.requester.getVisitorData({\n visitorCode,\n filters,\n isMappingIdentifier: isUniqueIdentifier,\n });\n const data = result.throw();\n\n const { visitorData, storageVisitorData, visitsData } =\n Utilities.parseVisitorData({\n data,\n filters,\n visitorCode,\n dataManager: this.dataManager,\n variationConfiguration: this.variationConfiguration,\n });\n\n for (const dataItem of storageVisitorData) {\n if (shouldAddData || this.dataManager.isPersistentCustomData(dataItem)) {\n this.addData(visitorCode, dataItem);\n }\n }\n\n // --- Note ---\n // Data on visits amount and time stamps is not returned to a user\n if (visitsData && shouldAddData) {\n this.addData(visitorCode, visitsData);\n }\n\n return visitorData;\n }\n\n public trackConversion({\n visitorCode,\n goalId,\n revenue,\n isUniqueIdentifier,\n }: TrackConversionParamsType): void {\n this.addData(visitorCode, new Conversion({ goalId, revenue }));\n this.flush(visitorCode, isUniqueIdentifier);\n }\n\n public flush(visitorCode?: string, isUniqueIdentifier?: boolean): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n if (typeof visitorCode === 'string') {\n Utilities.validateVisitorCode(visitorCode).throw();\n }\n\n if (visitorCode) {\n let isMappingIdentifier = false;\n\n // --- Note ---\n // This part is a workaround for Data API\n // If there's is no unique identifier for the visitor\n // We do reconciliation for visitor with himself\n if (isUniqueIdentifier) {\n const linkedVisitor = this.dataManager.getLinkedVisitor(visitorCode);\n const index = this.dataManager.identifierCustomDataIndex;\n\n if (!linkedVisitor && typeof index === 'number') {\n this.dataManager.addData(\n visitorCode,\n new CustomData(index, visitorCode),\n );\n } else {\n isMappingIdentifier = true;\n }\n }\n\n Utilities.trackData({\n visitorCode,\n isMappingIdentifier,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n\n return;\n }\n\n // --- Note ---\n // `Utilities.trackData` executes `Utilities.sendOfflineTracking` asynchronously at first, but\n // we need to execute `Utilities.sendOfflineTracking` even if calling `Utilities.trackData` is skipped\n // due to lack of unsent data\n if (!this.dataManager.unsentDataVisitors.length) {\n Utilities.sendOfflineTracking({\n requester: this.requester,\n storage: this.offlineTrackingStorage,\n });\n return;\n }\n\n for (const visitorCodeKey of this.dataManager.unsentDataVisitors) {\n Utilities.trackData({\n visitorCode: visitorCodeKey,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCodeKey),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n }\n }\n\n public getFeatureFlags(): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n return this.clientConfiguration.featureFlags.map(({ id, featureKey }) => ({\n id,\n key: featureKey,\n }));\n }\n\n public getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n const targetingData = this.dataManager.getTargetingData(visitorCode);\n const visitorIdentifier =\n this.dataManager.getVisitorIdentifier(visitorCode);\n\n for (const featureFlag of featureFlags) {\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n visitorIdentifier,\n targetingData,\n featureFlag,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n if (\n variationData.variationKey !== OFF_VARIATION_KEY &&\n featureFlag.environmentEnabled\n ) {\n const { featureFlagId, featureKey } = variationData;\n\n resultFeatureFlags.push({ id: featureFlagId, key: featureKey });\n }\n }\n\n return resultFeatureFlags;\n }\n\n public getFeatureFlagVariationKey(\n visitorCode: string,\n featureKey: string,\n ): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n return variationKey;\n }\n\n public getFeatureFlagVariable({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType): FeatureFlagVariableType {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const featureFlags = this.clientConfiguration.featureFlags;\n\n const featureFlag = featureFlags.find(\n (item) => item.featureKey === featureKey,\n );\n\n if (!featureFlag) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n );\n }\n\n const variable = featureFlag.variations\n .find((item) => item.key === variationKey)\n ?.variables.find((item) => item.key === variableKey);\n\n if (!variable) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariableNotFound,\n variableKey,\n visitorCode,\n );\n }\n\n const { type, value } = Utilities.parseFeatureVariable(variable).throw();\n\n return { type, value } as FeatureFlagVariableType;\n }\n\n public getFeatureFlagVariables(\n visitorCode: string,\n featureKey: string,\n ): FeatureVariableResultType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const featureFlags = this.clientConfiguration.featureFlags;\n\n const featureFlag = featureFlags.find(\n (item) => item.featureKey === featureKey,\n );\n\n if (!featureFlag) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n );\n }\n\n const variation = featureFlag.variations.find(\n (item) => item.key === variationKey,\n );\n\n if (!variation) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariationNotFound,\n variationKey,\n visitorCode,\n );\n }\n\n const variables: FeatureVariableResultType[] = [];\n\n for (const variable of variation.variables) {\n const parsedVariable = Utilities.parseFeatureVariable(variable).throw();\n variables.push(parsedVariable);\n }\n\n return variables;\n }\n\n public isFeatureFlagActive(visitorCode: string, featureKey: string): boolean {\n try {\n const variationKey = this.getFeatureFlagVariationKey(\n visitorCode,\n featureKey,\n );\n\n return variationKey !== OFF_VARIATION_KEY;\n } catch (err) {\n if (\n err instanceof KameleoonError &&\n err.type === KameleoonException.FeatureFlagEnvironmentDisabled\n ) {\n return false;\n }\n\n throw err;\n }\n }\n\n public async getRemoteData(key: string): Promise<JSONType> {\n const remoteData = await this.requester.getRemoteData(key);\n\n return remoteData.throw();\n }\n\n public async getVisitorWarehouseAudience({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType): Promise<CustomData | null> {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const data = await this.getRemoteData(warehouseKey || visitorCode);\n\n if (!data) {\n throw new KameleoonError(KameleoonException.RemoteData);\n }\n\n if (\n !data[WAREHOUSE_AUDIENCE_KEY] ||\n Object.keys(data[WAREHOUSE_AUDIENCE_KEY]).length === 0\n ) {\n return null;\n }\n\n const customData = new CustomData(\n customDataIndex,\n ...Object.keys(data[WAREHOUSE_AUDIENCE_KEY]),\n );\n\n this.dataManager.addData(visitorCode, customData);\n\n return customData;\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.clientConfiguration.onConfigurationUpdate(callback);\n }\n\n public getEngineTrackingCode(visitorCode: string): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n return Utilities.getTrackingCode(this.trackingCache, visitorCode);\n }\n\n public isInitialized(): boolean {\n return this.initialized;\n }\n\n protected setUserConsent({\n visitorCode,\n consent,\n setData,\n }: SetUserConsentParametersType): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n this.consentDataStorage.update({ [visitorCode]: consent });\n\n if (consent) {\n setData({\n visitorCode,\n key: KameleoonStorageKey.VisitorCode,\n maxAge: DEFAULT_MAX_AGE,\n path: PATH,\n });\n } else {\n if (this.visitorCodeManager.consentRequired) {\n setData({\n visitorCode: '',\n key: KameleoonStorageKey.VisitorCode,\n maxAge: ZERO_MAX_AGE,\n path: PATH,\n });\n }\n }\n }\n\n private _isConsentProvided(visitorCode: string): boolean {\n const { isConsentRequired } = this.clientConfiguration;\n const consentDataResult = this.consentDataStorage.read();\n\n return (\n !isConsentRequired ||\n (consentDataResult.ok && consentDataResult.data[visitorCode])\n );\n }\n\n private _getFeatureFlagVariation(\n visitorCode: string,\n featureKey: string,\n ): Result<FeatureFlagVariationType, KameleoonError> {\n if (!this.initialized) {\n return Err(new KameleoonError(KameleoonException.Initialization));\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const featureFlag = featureFlags.find(\n (item) => item.featureKey === featureKey,\n );\n\n if (!featureFlag) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n ),\n );\n }\n\n if (!featureFlag.environmentEnabled) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagEnvironmentDisabled,\n featureFlag.featureKey,\n this.environment || Environment.Production,\n ),\n );\n }\n\n const targetingData = this.dataManager.getTargetingData(visitorCode);\n const visitorIdentifier =\n this.dataManager.getVisitorIdentifier(visitorCode);\n\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n visitorIdentifier,\n featureFlag,\n targetingData,\n withAssignment: true,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n const { experimentId, variationId } = variationData;\n\n if (typeof variationId === 'number' && typeof experimentId === 'number') {\n Utilities.updateCache({\n cacheManager: this.trackingCache,\n visitorCode,\n experimentId,\n variationId,\n });\n }\n\n Utilities.trackFeatureExperiment({\n visitorCode,\n requester: this.requester,\n featureFlagVariation: variationData,\n dataManager: this.dataManager,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n variationConfiguration: this.variationConfiguration,\n });\n\n return Ok(variationData);\n }\n}\n"],"mappings":"upCAyDO,KAAM,CAAAA,eAA4C,CAiBvDC,WAAWA,CAAAC,CAAA,CAIW,IAJV,CACVC,QAAQ,CAARA,CAAQ,CACRC,aAAa,CAAbA,CAAa,CACbC,qBAAqB,CAArBA,CACiB,CAAC,CAAAH,CAAA,CAAAI,eAAA,uCAAAA,eAAA,oCAAAA,eAAA,4BAAAA,eAAA,uCAAAA,eAAA,mCAAAA,eAAA,8BAAAA,eAAA,0BAAAA,eAAA,oCAAAA,eAAA,gCAAAA,eAAA,wBAAAA,eAAA,4BAAAA,eAAA,mCAClB,KAAM,CAAEC,QAAQ,CAAEC,CAAe,CAAC,CAAG,GAAI,CAAAC,8BAAc,CACrDN,CAAQ,CACRC,CACF,CAAC,CACD,IAAI,CAACM,WAAW,CAAGF,CAAc,CAACE,WAAW,MACvC,C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AW,CAAC,CACvD5B,sBAAsB,CAAE,IAAI,CAACA,sBAAsB,CACnDiB,sBAAsB,CAAE,IAAI,CAACA,sBAC/B,CAAC,CAAC,CAEK,GAAAsI,SAAE,EAACnE,CAAa,CACzB,CACF,CAACoE,OAAA,CAAApL,eAAA,CAAAA,eAAA"}
1
+ {"version":3,"file":"kameleoonClient.js","names":["KameleoonClient","constructor","a","siteCode","configuration","internalConfiguration","_defineProperty","settings","clientSettings","ClientSettings","environment","externalStorage","externalEventSource","externalPackageInfo","externalVisitorCodeManager","externalRequestDispatcher","externalClientConfiguration","trackingCache","CacheManager","CACHE_CLEANUP_TIMEOUT","clientDataStorage","DataStorage","KameleoonStorageKey","ClientData","targetingDataStorage","TargetingData","variationDataStorage","VariationData","offlineTrackingStorage","OfflineTracking","consentDataStorage","ConsentData","dataManager","DataManager","storage","targetingCleanupInterval","targetingDataCleanupInterval","eventSource","KameleoonEventSource","requester","Requester","packageInfo","requestDispatcher","clientConfiguration","ClientConfiguration","variationConfiguration","VariationConfiguration","visitorCodeManager","initialize","useCache","result","throw","isOfflineModeOn","initialized","ok","addData","visitorCode","Utilities","validateVisitorCode","KameleoonError","KameleoonException","Initialization","b","arguments","length","data","Array","d","getRemoteVisitorData","shouldAddData","filters","DEFAULT_VISITOR_DATA_FILTERS","isUniqueIdentifier","previousVisitAmount","VisitAmount","getVisitorData","isMappingIdentifier","visitorData","storageVisitorData","visitsData","parseVisitorData","dataItem","isPersistentCustomData","trackConversion","goalId","revenue","Conversion","flush","linkedVisitor","getLinkedVisitor","index","identifierCustomDataIndex","CustomData","trackData","isConsentProvided","_isConsentProvided","unsentDataVisitors","sendOfflineTracking","visitorCodeKey","getFeatureFlags","featureFlags","resultFeatureFlags","forEach","id","featureKey","push","key","getVisitorFeatureFlags","activeVariations","_getActiveFeatureVariations","featureFlagId","getActiveFeatureFlags","resultFeatureList","Map","variation","variationKey","variationId","experimentId","variables","_getFeatureVariables","resultVariables","map","variable","parseFeatureVariable","set","getFeatureFlagVariationKey","_getFeatureVariation","getFeatureFlagVariable","variableKey","find","item","FeatureFlagVariableNotFound","type","value","getFeatureFlagVariables","parsedVariable","isFeatureFlagActive","OFF_VARIATION_KEY","err","FeatureFlagEnvironmentDisabled","getRemoteData","remoteData","getVisitorWarehouseAudience","customDataIndex","warehouseKey","RemoteData","WAREHOUSE_AUDIENCE_KEY","Object","keys","customData","onConfigurationUpdate","callback","getEngineTrackingCode","getTrackingCode","isInitialized","setUserConsent","consent","setData","update","VisitorCode","maxAge","DEFAULT_MAX_AGE","path","PATH","consentRequired","ZERO_MAX_AGE","isConsentRequired","consentDataResult","read","featureFlag","get","FeatureFlagConfigurationNotFound","variations","FeatureFlagVariationNotFound","targetingData","getTargetingData","visitorIdentifier","getVisitorIdentifier","values","environmentEnabled","variationData","getVariation","Err","Environment","Production","withAssignment","updateCache","cacheManager","trackFeatureExperiment","featureFlagVariation","Ok","exports"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CacheManager } from './cacheManager';\nimport {\n ClientConfiguration,\n FeatureVariableType,\n JSONType,\n} from './clientConfiguration';\nimport { ClientSettings } from './clientSettings';\nimport {\n CACHE_CLEANUP_TIMEOUT,\n DEFAULT_VISITOR_DATA_FILTERS,\n OFF_VARIATION_KEY,\n} from './constants';\nimport {\n Conversion,\n CustomData,\n DataManager,\n KameleoonDataType,\n} from './kameleoonData';\nimport { WAREHOUSE_AUDIENCE_KEY } from './constants';\nimport { KameleoonError, KameleoonException } from './kameleoonError';\nimport { Requester } from './requester';\nimport {\n ClientDataType,\n KameleoonStorageKey,\n VariationDataType,\n DataStorage,\n ConsentDataType,\n IStorage,\n OfflineTracking,\n} from './storage';\nimport {\n TrackConversionParamsType,\n FeatureFlagType,\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n SDKCoreParameters,\n TrackingCacheItemType,\n ExternalPackageInfoType,\n RemoteVisitorDataParamsType,\n GetVisitorWarehouseAudienceParamsType,\n Environment,\n SetUserConsentParametersType,\n FeatureFlagVariableType,\n KameleoonVariationType,\n GetFeatureVariablesParamsType,\n} from './types';\nimport { IVisitorCodeManager } from './visitorCodeManager';\nimport { Utilities } from './utilities';\nimport {\n FeatureFlagVariationType,\n VariationConfiguration,\n} from './variationConfiguration';\nimport { TargetingDataType } from './targeting';\nimport { KameleoonEventSource } from './eventSource';\nimport { IKameleoonClient } from './kameleoonClientInterface';\nimport { DEFAULT_MAX_AGE, PATH, ZERO_MAX_AGE } from './visitorCodeManager';\n\n/**\n * @class\n * KameleoonClient - a class for creating kameleoon client instance\n * for communicating with Kameleoon JavaScript SDK Core, when new instance is created\n */\nexport class KameleoonClient implements IKameleoonClient {\n private variationConfiguration: VariationConfiguration;\n private clientConfiguration: ClientConfiguration;\n private dataManager: DataManager;\n private offlineTrackingStorage: IStorage<OfflineTracking>;\n private consentDataStorage: IStorage<ConsentDataType>;\n private trackingCache: CacheManager<TrackingCacheItemType>;\n private requester: Requester;\n private externalPackageInfo: ExternalPackageInfoType;\n private isOfflineModeOn?: boolean;\n private initialized: boolean = false;\n private environment?: Environment;\n private visitorCodeManager: IVisitorCodeManager;\n\n /**\n * @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core\n */\n constructor({\n siteCode,\n configuration,\n internalConfiguration,\n }: SDKCoreParameters) {\n const { settings: clientSettings } = new ClientSettings(\n siteCode,\n configuration,\n );\n this.environment = clientSettings.environment;\n const {\n externalStorage,\n externalEventSource,\n externalPackageInfo,\n externalVisitorCodeManager,\n externalRequestDispatcher,\n externalClientConfiguration,\n } = internalConfiguration;\n const trackingCache = new CacheManager<TrackingCacheItemType>(\n CACHE_CLEANUP_TIMEOUT,\n );\n\n const clientDataStorage = new DataStorage<ClientDataType>(\n externalStorage,\n KameleoonStorageKey.ClientData,\n );\n const targetingDataStorage = new DataStorage<TargetingDataType>(\n externalStorage,\n KameleoonStorageKey.TargetingData,\n );\n const variationDataStorage = new DataStorage<VariationDataType>(\n externalStorage,\n KameleoonStorageKey.VariationData,\n );\n const offlineTrackingStorage = new DataStorage<OfflineTracking>(\n externalStorage,\n KameleoonStorageKey.OfflineTracking,\n );\n const consentDataStorage = new DataStorage<ConsentDataType>(\n externalStorage,\n KameleoonStorageKey.ConsentData,\n );\n\n const dataManager = new DataManager({\n storage: targetingDataStorage,\n targetingCleanupInterval: configuration?.targetingDataCleanupInterval,\n });\n\n const eventSource = new KameleoonEventSource(\n clientSettings.siteCode,\n externalEventSource,\n );\n\n const requester = new Requester({\n siteCode,\n environment: clientSettings.environment,\n packageInfo: externalPackageInfo,\n requestDispatcher: externalRequestDispatcher,\n });\n\n const clientConfiguration = new ClientConfiguration({\n settings: clientSettings,\n storage: clientDataStorage,\n dataManager,\n requester,\n externalClientConfiguration,\n offlineTrackingStorage,\n eventSource,\n externalVisitorCodeManager,\n });\n\n const variationConfiguration = new VariationConfiguration(\n variationDataStorage,\n );\n\n this.variationConfiguration = variationConfiguration;\n this.requester = requester;\n this.trackingCache = trackingCache;\n this.dataManager = dataManager;\n this.clientConfiguration = clientConfiguration;\n this.externalPackageInfo = externalPackageInfo;\n this.offlineTrackingStorage = offlineTrackingStorage;\n this.consentDataStorage = consentDataStorage;\n this.visitorCodeManager = externalVisitorCodeManager;\n }\n\n public async initialize(useCache?: boolean): Promise<boolean> {\n const result = await this.clientConfiguration.initialize();\n result.throw();\n\n this.isOfflineModeOn = useCache;\n this.initialized = true;\n\n return result.ok;\n }\n\n public addData(visitorCode: string, ...data: KameleoonDataType[]): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.dataManager.addData(visitorCode, ...data).throw();\n }\n\n public async getRemoteVisitorData({\n visitorCode,\n shouldAddData = true,\n filters = DEFAULT_VISITOR_DATA_FILTERS,\n isUniqueIdentifier = false,\n }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]> {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { previousVisitAmount } = filters;\n\n if (\n typeof previousVisitAmount === 'number' &&\n (previousVisitAmount < 1 || previousVisitAmount > 25)\n ) {\n throw new KameleoonError(KameleoonException.VisitAmount);\n }\n\n const result = await this.requester.getVisitorData({\n visitorCode,\n filters,\n isMappingIdentifier: isUniqueIdentifier,\n });\n const data = result.throw();\n\n const { visitorData, storageVisitorData, visitsData } =\n Utilities.parseVisitorData({\n data,\n filters,\n visitorCode,\n dataManager: this.dataManager,\n variationConfiguration: this.variationConfiguration,\n });\n\n for (const dataItem of storageVisitorData) {\n if (shouldAddData || this.dataManager.isPersistentCustomData(dataItem)) {\n this.addData(visitorCode, dataItem);\n }\n }\n\n // --- Note ---\n // Data on visits amount and time stamps is not returned to a user\n if (visitsData && shouldAddData) {\n this.addData(visitorCode, visitsData);\n }\n\n return visitorData;\n }\n\n public trackConversion({\n visitorCode,\n goalId,\n revenue,\n isUniqueIdentifier,\n }: TrackConversionParamsType): void {\n this.addData(visitorCode, new Conversion({ goalId, revenue }));\n this.flush(visitorCode, isUniqueIdentifier);\n }\n\n public flush(visitorCode?: string, isUniqueIdentifier?: boolean): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n if (typeof visitorCode === 'string') {\n Utilities.validateVisitorCode(visitorCode).throw();\n }\n\n if (visitorCode) {\n let isMappingIdentifier = false;\n\n // --- Note ---\n // This part is a workaround for Data API\n // If there's is no unique identifier for the visitor\n // We do reconciliation for visitor with himself\n if (isUniqueIdentifier) {\n const linkedVisitor = this.dataManager.getLinkedVisitor(visitorCode);\n const index = this.dataManager.identifierCustomDataIndex;\n\n if (!linkedVisitor && typeof index === 'number') {\n this.dataManager.addData(\n visitorCode,\n new CustomData(index, visitorCode),\n );\n } else {\n isMappingIdentifier = true;\n }\n }\n\n Utilities.trackData({\n visitorCode,\n isMappingIdentifier,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n\n return;\n }\n\n // --- Note ---\n // `Utilities.trackData` executes `Utilities.sendOfflineTracking` asynchronously at first, but\n // we need to execute `Utilities.sendOfflineTracking` even if calling `Utilities.trackData` is skipped\n // due to lack of unsent data\n if (!this.dataManager.unsentDataVisitors.length) {\n Utilities.sendOfflineTracking({\n requester: this.requester,\n storage: this.offlineTrackingStorage,\n });\n return;\n }\n\n for (const visitorCodeKey of this.dataManager.unsentDataVisitors) {\n Utilities.trackData({\n visitorCode: visitorCodeKey,\n dataManager: this.dataManager,\n requester: this.requester,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCodeKey),\n offlineTrackingStorage: this.offlineTrackingStorage,\n });\n }\n }\n\n public getFeatureFlags(): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n featureFlags.forEach(({ id, featureKey }) => {\n resultFeatureFlags.push({\n id,\n key: featureKey,\n });\n });\n\n return resultFeatureFlags;\n }\n\n public getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const activeVariations = this._getActiveFeatureVariations(visitorCode);\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n activeVariations.forEach(({ featureFlagId, featureKey }) => {\n resultFeatureFlags.push({\n id: featureFlagId,\n key: featureKey,\n });\n });\n\n return resultFeatureFlags;\n }\n\n public getActiveFeatureFlags(\n visitorCode: string,\n ): Map<string, KameleoonVariationType> {\n const activeVariations = this._getActiveFeatureVariations(visitorCode);\n const resultFeatureList: Map<string, KameleoonVariationType> = new Map();\n\n activeVariations.forEach((variation) => {\n const { variationKey, featureKey, variationId, experimentId } = variation;\n\n let variables: FeatureVariableType[] = [];\n\n if (variationId !== null && experimentId !== null) {\n variables = this._getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n });\n }\n\n const resultVariables = variables.map((variable) =>\n Utilities.parseFeatureVariable(variable).throw(),\n );\n\n resultFeatureList.set(variation.featureKey, {\n key: variationKey,\n id: variationId,\n experimentId,\n variables: resultVariables,\n });\n });\n\n return resultFeatureList;\n }\n\n public getFeatureFlagVariationKey(\n visitorCode: string,\n featureKey: string,\n ): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n return variationKey;\n }\n\n public getFeatureFlagVariable({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType): FeatureFlagVariableType {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const variables = this._getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n });\n const variable = variables.find((item) => item.key === variableKey);\n\n if (!variable) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariableNotFound,\n variableKey,\n visitorCode,\n );\n }\n\n const { type, value } = Utilities.parseFeatureVariable(variable).throw();\n\n return { type, value } as FeatureFlagVariableType;\n }\n\n public getFeatureFlagVariables(\n visitorCode: string,\n featureKey: string,\n ): FeatureVariableResultType[] {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const { variationKey } = this._getFeatureVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n const variables = this._getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n });\n const resultVariables: FeatureVariableResultType[] = [];\n\n for (const variable of variables) {\n const parsedVariable = Utilities.parseFeatureVariable(variable).throw();\n resultVariables.push(parsedVariable);\n }\n\n return resultVariables;\n }\n\n public isFeatureFlagActive(visitorCode: string, featureKey: string): boolean {\n try {\n const variationKey = this.getFeatureFlagVariationKey(\n visitorCode,\n featureKey,\n );\n\n return variationKey !== OFF_VARIATION_KEY;\n } catch (err) {\n if (\n err instanceof KameleoonError &&\n err.type === KameleoonException.FeatureFlagEnvironmentDisabled\n ) {\n return false;\n }\n\n throw err;\n }\n }\n\n public async getRemoteData(key: string): Promise<JSONType> {\n const remoteData = await this.requester.getRemoteData(key);\n\n return remoteData.throw();\n }\n\n public async getVisitorWarehouseAudience({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType): Promise<CustomData | null> {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const data = await this.getRemoteData(warehouseKey || visitorCode);\n\n if (!data) {\n throw new KameleoonError(KameleoonException.RemoteData);\n }\n\n if (\n !data[WAREHOUSE_AUDIENCE_KEY] ||\n Object.keys(data[WAREHOUSE_AUDIENCE_KEY]).length === 0\n ) {\n return null;\n }\n\n const customData = new CustomData(\n customDataIndex,\n ...Object.keys(data[WAREHOUSE_AUDIENCE_KEY]),\n );\n\n this.dataManager.addData(visitorCode, customData);\n\n return customData;\n }\n\n public onConfigurationUpdate(callback: () => void): void {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.clientConfiguration.onConfigurationUpdate(callback);\n }\n\n public getEngineTrackingCode(visitorCode: string): string {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n return Utilities.getTrackingCode(this.trackingCache, visitorCode);\n }\n\n public isInitialized(): boolean {\n return this.initialized;\n }\n\n protected setUserConsent({\n visitorCode,\n consent,\n setData,\n }: SetUserConsentParametersType): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n this.consentDataStorage.update({ [visitorCode]: consent });\n\n if (consent) {\n setData({\n visitorCode,\n key: KameleoonStorageKey.VisitorCode,\n maxAge: DEFAULT_MAX_AGE,\n path: PATH,\n });\n } else {\n if (this.visitorCodeManager.consentRequired) {\n setData({\n visitorCode: '',\n key: KameleoonStorageKey.VisitorCode,\n maxAge: ZERO_MAX_AGE,\n path: PATH,\n });\n }\n }\n }\n\n private _isConsentProvided(visitorCode: string): boolean {\n const { isConsentRequired } = this.clientConfiguration;\n const consentDataResult = this.consentDataStorage.read();\n\n return (\n !isConsentRequired ||\n (consentDataResult.ok && consentDataResult.data[visitorCode])\n );\n }\n\n private _getFeatureVariables({\n visitorCode,\n featureKey,\n variationKey,\n }: GetFeatureVariablesParamsType): FeatureVariableType[] {\n const featureFlags = this.clientConfiguration.featureFlags;\n const featureFlag = featureFlags.get(featureKey);\n\n if (!featureFlag) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n );\n }\n const variation = featureFlag.variations.find(\n (item) => item.key === variationKey,\n );\n\n if (!variation) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagVariationNotFound,\n variationKey,\n visitorCode,\n );\n }\n\n return variation.variables;\n }\n\n private _getActiveFeatureVariations(\n visitorCode: string,\n ): FeatureFlagVariationType[] {\n if (!this.initialized) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const activeVariations: FeatureFlagVariationType[] = [];\n\n const targetingData = this.dataManager.getTargetingData(visitorCode);\n const visitorIdentifier =\n this.dataManager.getVisitorIdentifier(visitorCode);\n\n for (const featureFlag of featureFlags.values()) {\n if (!featureFlag.environmentEnabled) {\n continue;\n }\n\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n visitorIdentifier,\n targetingData,\n featureFlag,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n if (variationData.variationKey !== OFF_VARIATION_KEY) {\n activeVariations.push(variationData);\n }\n }\n\n return activeVariations;\n }\n\n private _getFeatureVariation(\n visitorCode: string,\n featureKey: string,\n ): Result<FeatureFlagVariationType, KameleoonError> {\n if (!this.initialized) {\n return Err(new KameleoonError(KameleoonException.Initialization));\n }\n\n const featureFlags = this.clientConfiguration.featureFlags;\n const featureFlag = featureFlags.get(featureKey);\n\n if (!featureFlag) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n ),\n );\n }\n\n if (!featureFlag.environmentEnabled) {\n return Err(\n new KameleoonError(\n KameleoonException.FeatureFlagEnvironmentDisabled,\n featureFlag.featureKey,\n this.environment || Environment.Production,\n ),\n );\n }\n\n const targetingData = this.dataManager.getTargetingData(visitorCode);\n const visitorIdentifier =\n this.dataManager.getVisitorIdentifier(visitorCode);\n\n const variationData = this.variationConfiguration\n .getVariation({\n visitorCode,\n visitorIdentifier,\n featureFlag,\n targetingData,\n withAssignment: true,\n clientConfiguration: this.clientConfiguration,\n dataManager: this.dataManager,\n packageInfo: this.externalPackageInfo,\n })\n .throw();\n\n const { experimentId, variationId } = variationData;\n\n if (typeof variationId === 'number' && typeof experimentId === 'number') {\n Utilities.updateCache({\n cacheManager: this.trackingCache,\n visitorCode,\n experimentId,\n variationId,\n });\n }\n\n Utilities.trackFeatureExperiment({\n visitorCode,\n requester: this.requester,\n featureFlagVariation: variationData,\n dataManager: this.dataManager,\n isOfflineModeOn: this.isOfflineModeOn,\n isConsentProvided: this._isConsentProvided(visitorCode),\n offlineTrackingStorage: this.offlineTrackingStorage,\n variationConfiguration: this.variationConfiguration,\n });\n\n return Ok(variationData);\n }\n}\n"],"mappings":"upCA+DO,KAAM,CAAAA,eAA4C,CAiBvDC,WAAWA,CAAAC,CAAA,CAIW,IAJV,CACVC,QAAQ,CAARA,CAAQ,CACRC,aAAa,CAAbA,CAAa,CACbC,qBAAqB,CAArBA,CACiB,CAAC,CAAAH,CAAA,CAAAI,eAAA,uCAAAA,eAAA,oCAAAA,eAAA,4BAAAA,eAAA,uCAAAA,eAAA,mCAAAA,eAAA,8BAAAA,eAAA,0BAAAA,eAAA,oCAAAA,eAAA,gCAAAA,eAAA,wBAAAA,eAAA,4BAAAA,eAAA,mCAClB,KAAM,CAAEC,QAAQ,CAAEC,CAAe,CAAC,CAAG,GAAI,CAAAC,8BAAc,CACrDN,CAAQ,CACRC,CACF,CAAC,CACD,IAA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AACA,WAAW,CAC7BoB,eAAe,CAAE,IAAI,CAACA,eAAe,CACrC0C,iBAAiB,CAAE,IAAI,CAACC,kBAAkB,CAACvC,CAAW,CAAC,CACvD5B,sBAAsB,CAAE,IAAI,CAACA,sBAAsB,CACnDiB,sBAAsB,CAAE,IAAI,CAACA,sBAC/B,CAAC,CAAC,CAEK,GAAAiJ,SAAE,EAACV,CAAa,CACzB,CACF,CAACW,OAAA,CAAA/L,eAAA,CAAAA,eAAA"}
@@ -1,6 +1,6 @@
1
1
  import { JSONType } from './clientConfiguration';
2
2
  import { CustomData, KameleoonDataType } from './kameleoonData';
3
- import { FeatureFlagType, FeatureFlagVariableType, FeatureVariableResultType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, RemoteVisitorDataParamsType, TrackConversionParamsType } from './types';
3
+ import { FeatureFlagType, FeatureFlagVariableType, FeatureVariableResultType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, KameleoonVariationType, RemoteVisitorDataParamsType, TrackConversionParamsType } from './types';
4
4
  /**
5
5
  * @interface an interface of KameleoonClient instance
6
6
  */
@@ -71,6 +71,9 @@ export interface IKameleoonClient {
71
71
  flush: (visitorCode?: string, isUniqueIdentifier?: boolean) => void;
72
72
  /**
73
73
  * @method getFeatureFlags - returns a list of feature flags stored in the client configuration
74
+ *
75
+ * Note: This method **doesn't send** tracking data
76
+ *
74
77
  * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields
75
78
  * @throws `KameleoonError` with one of the following `type` s:
76
79
  *
@@ -79,6 +82,9 @@ export interface IKameleoonClient {
79
82
  getFeatureFlags: () => FeatureFlagType[];
80
83
  /**
81
84
  * @method getVisitorFeatureFlags - returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).
85
+ *
86
+ * Note: This method **doesn't send** tracking data
87
+ *
82
88
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
83
89
  * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields
84
90
  * @throws `KameleoonError` with one of the following `type` s:
@@ -90,8 +96,28 @@ export interface IKameleoonClient {
90
96
  * - `KameleoonException.NotTargeted` - Current visitor is not targeted
91
97
  */
92
98
  getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];
99
+ /**
100
+ * @method getActiveFeatureFlags - method collecting all active feature flags information including it's variation and variables for the visitor
101
+ *
102
+ * Note: This method **doesn't send** tracking data
103
+ *
104
+ * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
105
+ * @returns {Map<string, KameleoonVariationType>} a map of feature flags with `featureKey` as a key and `KameleoonVariationType` as a value
106
+ * @throws `KameleoonError` with one of the following `type` s:
107
+ *
108
+ * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
109
+ * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
110
+ * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
111
+ * - `KameleoonException.StorageRead` - Couldn't read storage data
112
+ * - `KameleoonException.JSONParse` - Couldn't parse JSON value
113
+ * - `KameleoonException.NumberParse` - Couldn't parse Number value
114
+ */
115
+ getActiveFeatureFlags: (visitorCode: string) => Map<string, KameleoonVariationType>;
93
116
  /**
94
117
  * @method isFeatureFlagActive - returns a boolean indicating whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
118
+ *
119
+ * Note: This method **sends** tracking data
120
+ *
95
121
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
96
122
  * @param {string} featureKey - a unique key for feature flag
97
123
  * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`
@@ -107,6 +133,9 @@ export interface IKameleoonClient {
107
133
  isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;
108
134
  /**
109
135
  * @method getFeatureFlagVariationKey - returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
136
+ *
137
+ * Note: This method **sends** tracking data
138
+ *
110
139
  * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
111
140
  * @param {string} featureKey - a unique key for feature flag
112
141
  * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor
@@ -122,6 +151,9 @@ export interface IKameleoonClient {
122
151
  getFeatureFlagVariationKey: (visitorCode: string, featureKey: string) => string;
123
152
  /**
124
153
  * @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
154
+ *
155
+ * Note: This method **sends** tracking data
156
+ *
125
157
  * @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.
126
158
  * @returns {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.
127
159
  * @throws `KameleoonError` with one of the following `type` s:
@@ -139,6 +171,9 @@ export interface IKameleoonClient {
139
171
  getFeatureFlagVariable: ({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType) => FeatureFlagVariableType;
140
172
  /**
141
173
  * @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
174
+ *
175
+ * Note: This method **sends** tracking data
176
+ *
142
177
  * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters
143
178
  * @param {string} featureKey - a unique key for feature flag
144
179
  * @returns {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.
@@ -1 +1 @@
1
- {"version":3,"file":"kameleoonClientInterface.js","names":[],"sources":["../src/kameleoonClientInterface.ts"],"sourcesContent":["import { JSONType } from './clientConfiguration';\nimport { CustomData, KameleoonDataType } from './kameleoonData';\nimport {\n FeatureFlagType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n RemoteVisitorDataParamsType,\n TrackConversionParamsType,\n} from './types';\n\n/**\n * @interface an interface of KameleoonClient instance\n */\nexport interface IKameleoonClient {\n /**\n * @method initialize - an asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize(useCache?: boolean): Promise<boolean>;\n initialize(): Promise<boolean>;\n /**\n * @method addData - method for adding targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: userAgent data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {KameleoonDataType[]} kameleoonData - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData`, `filters` and `isUniqueIdentifier` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n isUniqueIdentifier,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n /**\n * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter\n * @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n */\n trackConversion: ({\n visitorCode,\n goalId,\n revenue,\n isUniqueIdentifier,\n }: TrackConversionParamsType) => void;\n /**\n * @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,\n * sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,\n * then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n flush: (visitorCode?: string, isUniqueIdentifier?: boolean) => void;\n /**\n * @method getFeatureFlags - returns a list of feature flags stored in the client configuration\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getFeatureFlags: () => FeatureFlagType[];\n /**\n * @method getVisitorFeatureFlags - returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n /**\n * @method isFeatureFlagActive - returns a boolean indicating whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;\n /**\n * @method getFeatureFlagVariationKey - returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string;\n /**\n * @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.\n * @returns {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariable: ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType) => FeatureFlagVariableType;\n /**\n * @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - a unique key for feature flag\n * @returns {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariables: (\n visitorCode: string,\n featureKey: string,\n ) => FeatureVariableResultType[];\n /**\n * @method getRemoteData - returns a data which is stored for specified siteCode on a remote Kameleoon server.\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {JSONType} - promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n /**\n * @method getVisitorWarehouseAudience - an async method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences\n * which is stored for specified visitorCode on a remote Kameleoon server.\n * Retrieved data will be added to storage under the specified `customDataIndex`\n * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details.\n * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getVisitorWarehouseAudience: ({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;\n /**\n * @method getEngineTrackingCode - returns Kameleoon tracking code for the current visitor. Tracking code is built of the experiments that were triggered and feature flag variations that were assigned during the last 5 seconds\n * See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {string} Kameleoon tracking code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getEngineTrackingCode: (visitorCode: string) => string;\n /**\n * @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.\n * @param {() => void} callback - callback function with no parameters that will be called upon configuration update\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n onConfigurationUpdate: (callback: () => void) => void;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"kameleoonClientInterface.js","names":[],"sources":["../src/kameleoonClientInterface.ts"],"sourcesContent":["import { JSONType } from './clientConfiguration';\nimport { CustomData, KameleoonDataType } from './kameleoonData';\nimport {\n FeatureFlagType,\n FeatureFlagVariableType,\n FeatureVariableResultType,\n GetFeatureFlagVariableParamsType,\n GetVisitorWarehouseAudienceParamsType,\n KameleoonVariationType,\n RemoteVisitorDataParamsType,\n TrackConversionParamsType,\n} from './types';\n\n/**\n * @interface an interface of KameleoonClient instance\n */\nexport interface IKameleoonClient {\n /**\n * @method initialize - an asynchronous method for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or update interval has not been reached\n * @param {boolean | undefined} useCache - optional parameter for activating SDK offline mode, if `true` is passed failed polls will not return error and will use cached data if such data is available, default value is `false`. Note: if offline mode is on, SDK will still try to retrieve the latest data.\n * @returns {Promise<boolean>} Promise resolved into boolean field indicating success or fail\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.ClientConfiguration` Couldn't retrieve client configuration from Kameleoon Api\n * - `KameleoonException.MaximumRetriesReached` Maximum retries reached, request failed\n */\n initialize(useCache?: boolean): Promise<boolean>;\n initialize(): Promise<boolean>;\n /**\n * @method addData - method for adding targeting data to the storage so that other methods could decide whether the current visitor is targeted or not. Note: userAgent data will not be stored in storage like other data, and it will be sent with every tracking request for bot filtration.\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {KameleoonDataType[]} kameleoonData - number of instances of any type of `KameleoonData`, can be added solely in array or as a sequential arguments\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.\n * @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData`, `filters` and `isUniqueIdentifier` parameters\n * @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n * - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getRemoteVisitorData: ({\n visitorCode,\n shouldAddData,\n filters,\n isUniqueIdentifier,\n }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;\n /**\n * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter\n * @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.StorageWrite` Couldn't update storage data\n */\n trackConversion: ({\n visitorCode,\n goalId,\n revenue,\n isUniqueIdentifier,\n }: TrackConversionParamsType) => void;\n /**\n * @method flush - takes visitor associated kameleoon data and sends the data tracking request with collected data,\n * sent data is removed from `KameleoonClient` instance but not from the storage for correct targeting checks. If no visitor is passed,\n * then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input\n * the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.\n * @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n flush: (visitorCode?: string, isUniqueIdentifier?: boolean) => void;\n /**\n * @method getFeatureFlags - returns a list of feature flags stored in the client configuration\n *\n * Note: This method **doesn't send** tracking data\n *\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n getFeatureFlags: () => FeatureFlagType[];\n /**\n * @method getVisitorFeatureFlags - returns a list of feature flags that the visitor with `visitorCode` that is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated).\n *\n * Note: This method **doesn't send** tracking data\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getVisitorFeatureFlags: (visitorCode: string) => FeatureFlagType[];\n /**\n * @method getActiveFeatureFlags - method collecting all active feature flags information including it's variation and variables for the visitor\n *\n * Note: This method **doesn't send** tracking data\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {Map<string, KameleoonVariationType>} a map of feature flags with `featureKey` as a key and `KameleoonVariationType` as a value\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.StorageRead` - Couldn't read storage data\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getActiveFeatureFlags: (\n visitorCode: string,\n ) => Map<string, KameleoonVariationType>;\n /**\n * @method isFeatureFlagActive - returns a boolean indicating whether the visitor with `visitorCode` has `featureKey` active for him, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {boolean} a boolean indicator of whether the feature flag with `featureKey` is active for visitor with `visitorCode`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n isFeatureFlagActive: (visitorCode: string, featureKey: string) => boolean;\n /**\n * @method getFeatureFlagVariationKey - returns variation key for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n *\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {string} featureKey - a unique key for feature flag\n * @returns {string} a string containing variable key for the allocated feature flag variation for the provided visitor\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n */\n getFeatureFlagVariationKey: (\n visitorCode: string,\n featureKey: string,\n ) => string;\n /**\n * @method getFeatureFlagVariable - returns a variable for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n *\n * @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.\n * @returns {FeatureFlagVariableType} a variable object containing `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariable: ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType) => FeatureFlagVariableType;\n /**\n * @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request\n *\n * Note: This method **sends** tracking data\n *\n * @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - a unique key for feature flag\n * @returns {FeatureVariableResultType[]} a list of variable objects containing `key`, `type` and `value` fields. You can check the `type` field against `VariableType` enum. For example, if the `type` is `VariableType.BOOLEAN` then `value` will be a `boolean` type.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`\n * - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`\n * - `KameleoonException.FeatureFlagEnvironmentDisabled` - The feature flag is disabled for the current environment\n * - `KameleoonException.JSONParse` - Couldn't parse JSON value\n * - `KameleoonException.NumberParse` - Couldn't parse Number value\n */\n getFeatureFlagVariables: (\n visitorCode: string,\n featureKey: string,\n ) => FeatureVariableResultType[];\n /**\n * @method getRemoteData - returns a data which is stored for specified siteCode on a remote Kameleoon server.\n * @param {string} key - unique key that the data you try to get is associated with.\n * @returns {JSONType} - promise with retrieving data for specific key.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getRemoteData: (key: string) => Promise<JSONType>;\n /**\n * @method getVisitorWarehouseAudience - an async method that returns a `CustomData` instance, containing data associated with a visitor's warehouse audiences\n * which is stored for specified visitorCode on a remote Kameleoon server.\n * Retrieved data will be added to storage under the specified `customDataIndex`\n * @param {GetVisitorWarehouseAudienceParamsType} parameters - an object with parameters of a type `GetVisitorWarehouseAudienceParamsType`, see the type for details.\n * @returns {Promise<CustomData | null>} `Promise` containing an instance of `CustomData` containing data associated with a visitor's warehouse audiences or `null` if the data was retrieved successfully but nothing was found under the specified `warehouseKey`\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` - The visitor code is empty\n * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server\n */\n getVisitorWarehouseAudience: ({\n visitorCode,\n customDataIndex,\n warehouseKey,\n }: GetVisitorWarehouseAudienceParamsType) => Promise<CustomData | null>;\n /**\n * @method getEngineTrackingCode - returns Kameleoon tracking code for the current visitor. Tracking code is built of the experiments that were triggered and feature flag variations that were assigned during the last 5 seconds\n * See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {string} Kameleoon tracking code\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.VisitorCodeEmpty` The visitor code is empty\n */\n getEngineTrackingCode: (visitorCode: string) => string;\n /**\n * @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.\n * @param {() => void} callback - callback function with no parameters that will be called upon configuration update\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call\n */\n onConfigurationUpdate: (callback: () => void) => void;\n}\n"],"mappings":""}
@@ -161,7 +161,7 @@ export type StrictFirstParameterRecord<T> = {
161
161
  [K in keyof T]: `?${Uncapitalize<K & string>}=`;
162
162
  };
163
163
  /**
164
- * @type HeadersType - a type of headers available in the request
164
+ * @type `HeadersType` - a type of headers available in the request
165
165
  * */
166
166
  export type HeadersType = Partial<Record<Header, string>>;
167
167
  export type TrackParametersType = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["HttpMethod","exports","Get","Post","DataApiQuery","VisitEvent","VisitData","DataMap","EVENT_TYPE_KEYS","PARAMETER_KEYS","TRACKING_KEYS","QUERY_KEYS"],"sources":["../../src/requester/types.ts"],"sourcesContent":["import { JSONType } from 'src/clientConfiguration';\nimport { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n BrowserIndexMap,\n BrowserType,\n OperatingSystemType,\n} from 'src/kameleoonData';\nimport {\n DeviceType,\n KCSType,\n OperatingSystemIndexMap,\n} from 'src/kameleoonData/types';\nimport { Header } from './constants';\nimport { VisitorDataFiltersType } from 'src/utilities';\n\nexport type UrlProviderInitializeParamsType = {\n siteCode: string;\n packageInfo: ExternalPackageInfoType;\n environment?: Environment;\n};\n\nexport type RequesterParamsType = {\n siteCode: string;\n environment?: Environment;\n packageInfo: ExternalPackageInfoType;\n requestDispatcher: IExternalRequestDispatcher;\n};\n\nexport type TrackExperimentParamsType = {\n dataUrl: string;\n variationDataUrl: string;\n visitorCode: string;\n isUnallocated: boolean;\n userAgent?: string;\n isTargetedRule?: boolean;\n};\n\nexport type TrackDataParamsType = {\n visitorCode: string;\n body: string;\n userAgent?: string;\n isMappingIdentifier?: boolean;\n};\n\nexport type GetVisitorDataParamsType = {\n visitorCode: string;\n filters: VisitorDataFiltersType;\n isMappingIdentifier?: boolean;\n};\n\nexport type GetVisitorDataUrlParamsType = {\n visitorCode: string;\n filters: VisitorDataFiltersType;\n isMappingIdentifier?: boolean;\n};\n\ntype EventDataType = {\n sdk?: {\n name: string;\n version: string;\n };\n itp: boolean;\n time: number;\n};\n\ntype CustomDataEventType = {\n data: {\n index: number;\n valuesCountMap: {\n [value: string]: number;\n };\n overwrite: boolean;\n mappingIdentifier: boolean;\n };\n} & EventDataType;\n\ntype ExperimentEventType = {\n data: {\n id: number;\n variationId: number;\n };\n} & EventDataType;\n\ntype ConversionEventType = {\n data: {\n goalId: number;\n revenue: number;\n negative: boolean;\n };\n} & EventDataType;\n\ntype BrowserIndexType = (typeof BrowserIndexMap)[BrowserType];\ntype OperatingSystemIndexType =\n (typeof OperatingSystemIndexMap)[OperatingSystemType];\n\nexport type PageEventType = {\n data: {\n href: string;\n canonicalHref: string | null;\n title: string;\n keyPagesIndices: number[] | [null];\n referrerHref: string | null;\n referrersIndices: number[] | [null];\n };\n} & EventDataType;\n\nexport type GeolocationEventType = {\n data: {\n country: string;\n region: string | null;\n city: string | null;\n postalCode: string | null;\n latitude: number | null;\n longitude: number | null;\n };\n} & EventDataType;\n\nexport type StaticDataEventType = {\n data: {\n visitNumber: number;\n timeSincePreviousVisit: number;\n firstReferrerHref: string | null;\n browser: BrowserType | null;\n browserIndex: BrowserIndexType | null;\n browserVersion: number | null;\n os: OperatingSystemType | null;\n osIndex: OperatingSystemIndexType | null;\n windowWidth: number | null;\n windowHeight: number | null;\n screenWidth: number | null;\n screenHeight: number | null;\n timeZoneId: string | null;\n localeLanguageTag: string | null;\n deviceType: DeviceType | null;\n mappingIdentifier: string | null;\n };\n} & EventDataType;\n\nexport type VisitType = {\n siteCode: string;\n visitorCode: string;\n timeStarted: number;\n customDataEvents?: CustomDataEventType[];\n experimentEvents?: ExperimentEventType[];\n conversionEvents?: ConversionEventType[];\n geolocationEvents?: GeolocationEventType[];\n staticDataEvent?: StaticDataEventType;\n pageEvents?: PageEventType[];\n};\n\nexport type GetVisitorDataResultType = {\n previousVisits?: VisitType[];\n currentVisit?: VisitType;\n kcs?: KCSType;\n};\n\nexport enum HttpMethod {\n Get = 'GET',\n Post = 'POST',\n}\n\nexport enum DataApiQuery {\n VisitEvent,\n VisitData,\n DataMap,\n}\n\nconst EVENT_TYPE_KEYS = [\n 'customData',\n 'staticData',\n 'page',\n 'conversion',\n 'geolocation',\n 'activity',\n 'experiment',\n] as const;\nconst PARAMETER_KEYS = [\n 'valuesCountMap',\n 'mappingValue',\n 'id',\n 'nonce',\n 'country',\n 'environment',\n 'city',\n 'region',\n 'latitude',\n 'geolocation',\n 'longitude',\n 'mappingIdentifier',\n 'postalCode',\n 'sdkName',\n 'sdkVersion',\n 'kcs',\n 'browserIndex',\n 'browserVersion',\n 'siteCode',\n 'visitorCode',\n 'currentVisit',\n 'maxNumberPreviousVisits',\n 'customData',\n 'negative',\n 'revenue',\n 'title',\n 'os',\n 'conversion',\n 'staticData',\n 'osIndex',\n 'browser',\n 'referrersIndices',\n 'overwrite',\n 'index',\n 'href',\n 'experiment',\n 'page',\n 'variationId',\n 'deviceType',\n 'goalId',\n 'ts',\n 'key',\n] as const;\nconst TRACKING_KEYS = ['visit', 'map'] as const;\nconst QUERY_KEYS = ['sse', 'visitor', 'map', 'events'] as const;\n\nexport type TrackingType = Record<\n Capitalize<(typeof TRACKING_KEYS)[number]>,\n string\n>;\nexport type QueryType = Record<Capitalize<(typeof QUERY_KEYS)[number]>, string>;\nexport type ParameterType = Record<\n Capitalize<(typeof PARAMETER_KEYS)[number]>,\n string\n>;\nexport type EventType = Record<\n Capitalize<(typeof EVENT_TYPE_KEYS)[number]>,\n string\n>;\n\nexport type StrictTrackingRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}/`;\n};\nexport type StrictQueryRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}?siteCode=`;\n};\nexport type StrictEventTypeRecord<T> = {\n [K in keyof T]: `eventType=${Uncapitalize<K & string>}`;\n};\nexport type StrictParameterRecord<T> = {\n [K in keyof T]: `&${Uncapitalize<K & string>}=`;\n};\nexport type StrictFirstParameterRecord<T> = {\n [K in keyof T]: `?${Uncapitalize<K & string>}=`;\n};\n\n/**\n * @type HeadersType - a type of headers available in the request\n * */\nexport type HeadersType = Partial<Record<Header, string>>;\n\nexport type TrackParametersType = {\n url: string;\n headers?: HeadersType;\n body: string;\n};\n\n/**\n * @interface an interface of External Request Dispatcher which will be used to perform requests.\n * */\nexport interface IExternalRequestDispatcher {\n /**\n * @method track - send a track request\n * @param {TrackParametersType} parameters - track parameters\n * */\n track: (params: TrackParametersType) => Promise<boolean>;\n /**\n * @method getClientConfiguration - get client configuration\n * @param {string} url - url address\n * @param {HeadersType} headers - headers\n * */\n getClientConfiguration: (\n url: string,\n headers: HeadersType,\n ) => Promise<JSONType>;\n /**\n * @method getRemoteData - get data from remote server of Kameleoon\n * @param {string} url - url address\n * */\n getRemoteData: (url: string) => Promise<JSONType>;\n}\n"],"mappings":"sHA4JY,CAAAA,UAAU,CAAAC,OAAA,CAAAD,UAAA,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAAE,GAAA,OAAVF,CAAU,CAAAG,IAAA,QAAVH,CAAU,MAKVI,YAAY,CAAAH,OAAA,CAAAG,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAC,UAAA,iBAAZD,CAAY,CAAZA,CAAY,CAAAE,SAAA,gBAAZF,CAAY,CAAZA,CAAY,CAAAG,OAAA,cAAZH,CAAY,WAMlB,CAAAI,eAAe,CAAG,CACtB,YAAY,CACZ,YAAY,CACZ,MAAM,CACN,YAAY,CACZ,aAAa,CACb,UAAU,CACV,YAAY,CACJ,CACJC,cAAc,CAAG,CACrB,gBAAgB,CAChB,cAAc,CACd,IAAI,CACJ,OAAO,CACP,SAAS,CACT,aAAa,CACb,MAAM,CACN,QAAQ,CACR,UAAU,CACV,aAAa,CACb,WAAW,CACX,mBAAmB,CACnB,YAAY,CACZ,SAAS,CACT,YAAY,CACZ,KAAK,CACL,cAAc,CACd,gBAAgB,CAChB,UAAU,CACV,aAAa,CACb,cAAc,CACd,yBAAyB,CACzB,YAAY,CACZ,UAAU,CACV,SAAS,CACT,OAAO,CACP,IAAI,CACJ,YAAY,CACZ,YAAY,CACZ,SAAS,CACT,SAAS,CACT,kBAAkB,CAClB,WAAW,CACX,OAAO,CACP,MAAM,CACN,YAAY,CACZ,MAAM,CACN,aAAa,CACb,YAAY,CACZ,QAAQ,CACR,IAAI,CACJ,KAAK,CACG,CACJC,aAAa,CAAG,CAAC,OAAO,CAAE,KAAK,CAAU,CACzCC,UAAU,CAAG,CAAC,KAAK,CAAE,SAAS,CAAE,KAAK,CAAE,QAAQ,CAAU"}
1
+ {"version":3,"file":"types.js","names":["HttpMethod","exports","Get","Post","DataApiQuery","VisitEvent","VisitData","DataMap","EVENT_TYPE_KEYS","PARAMETER_KEYS","TRACKING_KEYS","QUERY_KEYS"],"sources":["../../src/requester/types.ts"],"sourcesContent":["import { JSONType } from 'src/clientConfiguration';\nimport { Environment, ExternalPackageInfoType } from 'src/types';\nimport {\n BrowserIndexMap,\n BrowserType,\n OperatingSystemType,\n} from 'src/kameleoonData';\nimport {\n DeviceType,\n KCSType,\n OperatingSystemIndexMap,\n} from 'src/kameleoonData/types';\nimport { Header } from './constants';\nimport { VisitorDataFiltersType } from 'src/utilities';\n\nexport type UrlProviderInitializeParamsType = {\n siteCode: string;\n packageInfo: ExternalPackageInfoType;\n environment?: Environment;\n};\n\nexport type RequesterParamsType = {\n siteCode: string;\n environment?: Environment;\n packageInfo: ExternalPackageInfoType;\n requestDispatcher: IExternalRequestDispatcher;\n};\n\nexport type TrackExperimentParamsType = {\n dataUrl: string;\n variationDataUrl: string;\n visitorCode: string;\n isUnallocated: boolean;\n userAgent?: string;\n isTargetedRule?: boolean;\n};\n\nexport type TrackDataParamsType = {\n visitorCode: string;\n body: string;\n userAgent?: string;\n isMappingIdentifier?: boolean;\n};\n\nexport type GetVisitorDataParamsType = {\n visitorCode: string;\n filters: VisitorDataFiltersType;\n isMappingIdentifier?: boolean;\n};\n\nexport type GetVisitorDataUrlParamsType = {\n visitorCode: string;\n filters: VisitorDataFiltersType;\n isMappingIdentifier?: boolean;\n};\n\ntype EventDataType = {\n sdk?: {\n name: string;\n version: string;\n };\n itp: boolean;\n time: number;\n};\n\ntype CustomDataEventType = {\n data: {\n index: number;\n valuesCountMap: {\n [value: string]: number;\n };\n overwrite: boolean;\n mappingIdentifier: boolean;\n };\n} & EventDataType;\n\ntype ExperimentEventType = {\n data: {\n id: number;\n variationId: number;\n };\n} & EventDataType;\n\ntype ConversionEventType = {\n data: {\n goalId: number;\n revenue: number;\n negative: boolean;\n };\n} & EventDataType;\n\ntype BrowserIndexType = (typeof BrowserIndexMap)[BrowserType];\ntype OperatingSystemIndexType =\n (typeof OperatingSystemIndexMap)[OperatingSystemType];\n\nexport type PageEventType = {\n data: {\n href: string;\n canonicalHref: string | null;\n title: string;\n keyPagesIndices: number[] | [null];\n referrerHref: string | null;\n referrersIndices: number[] | [null];\n };\n} & EventDataType;\n\nexport type GeolocationEventType = {\n data: {\n country: string;\n region: string | null;\n city: string | null;\n postalCode: string | null;\n latitude: number | null;\n longitude: number | null;\n };\n} & EventDataType;\n\nexport type StaticDataEventType = {\n data: {\n visitNumber: number;\n timeSincePreviousVisit: number;\n firstReferrerHref: string | null;\n browser: BrowserType | null;\n browserIndex: BrowserIndexType | null;\n browserVersion: number | null;\n os: OperatingSystemType | null;\n osIndex: OperatingSystemIndexType | null;\n windowWidth: number | null;\n windowHeight: number | null;\n screenWidth: number | null;\n screenHeight: number | null;\n timeZoneId: string | null;\n localeLanguageTag: string | null;\n deviceType: DeviceType | null;\n mappingIdentifier: string | null;\n };\n} & EventDataType;\n\nexport type VisitType = {\n siteCode: string;\n visitorCode: string;\n timeStarted: number;\n customDataEvents?: CustomDataEventType[];\n experimentEvents?: ExperimentEventType[];\n conversionEvents?: ConversionEventType[];\n geolocationEvents?: GeolocationEventType[];\n staticDataEvent?: StaticDataEventType;\n pageEvents?: PageEventType[];\n};\n\nexport type GetVisitorDataResultType = {\n previousVisits?: VisitType[];\n currentVisit?: VisitType;\n kcs?: KCSType;\n};\n\nexport enum HttpMethod {\n Get = 'GET',\n Post = 'POST',\n}\n\nexport enum DataApiQuery {\n VisitEvent,\n VisitData,\n DataMap,\n}\n\nconst EVENT_TYPE_KEYS = [\n 'customData',\n 'staticData',\n 'page',\n 'conversion',\n 'geolocation',\n 'activity',\n 'experiment',\n] as const;\nconst PARAMETER_KEYS = [\n 'valuesCountMap',\n 'mappingValue',\n 'id',\n 'nonce',\n 'country',\n 'environment',\n 'city',\n 'region',\n 'latitude',\n 'geolocation',\n 'longitude',\n 'mappingIdentifier',\n 'postalCode',\n 'sdkName',\n 'sdkVersion',\n 'kcs',\n 'browserIndex',\n 'browserVersion',\n 'siteCode',\n 'visitorCode',\n 'currentVisit',\n 'maxNumberPreviousVisits',\n 'customData',\n 'negative',\n 'revenue',\n 'title',\n 'os',\n 'conversion',\n 'staticData',\n 'osIndex',\n 'browser',\n 'referrersIndices',\n 'overwrite',\n 'index',\n 'href',\n 'experiment',\n 'page',\n 'variationId',\n 'deviceType',\n 'goalId',\n 'ts',\n 'key',\n] as const;\nconst TRACKING_KEYS = ['visit', 'map'] as const;\nconst QUERY_KEYS = ['sse', 'visitor', 'map', 'events'] as const;\n\nexport type TrackingType = Record<\n Capitalize<(typeof TRACKING_KEYS)[number]>,\n string\n>;\nexport type QueryType = Record<Capitalize<(typeof QUERY_KEYS)[number]>, string>;\nexport type ParameterType = Record<\n Capitalize<(typeof PARAMETER_KEYS)[number]>,\n string\n>;\nexport type EventType = Record<\n Capitalize<(typeof EVENT_TYPE_KEYS)[number]>,\n string\n>;\n\nexport type StrictTrackingRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}/`;\n};\nexport type StrictQueryRecord<T> = {\n [K in keyof T]: `${Uncapitalize<K & string>}?siteCode=`;\n};\nexport type StrictEventTypeRecord<T> = {\n [K in keyof T]: `eventType=${Uncapitalize<K & string>}`;\n};\nexport type StrictParameterRecord<T> = {\n [K in keyof T]: `&${Uncapitalize<K & string>}=`;\n};\nexport type StrictFirstParameterRecord<T> = {\n [K in keyof T]: `?${Uncapitalize<K & string>}=`;\n};\n\n/**\n * @type `HeadersType` - a type of headers available in the request\n * */\nexport type HeadersType = Partial<Record<Header, string>>;\n\nexport type TrackParametersType = {\n url: string;\n headers?: HeadersType;\n body: string;\n};\n\n/**\n * @interface an interface of External Request Dispatcher which will be used to perform requests.\n * */\nexport interface IExternalRequestDispatcher {\n /**\n * @method track - send a track request\n * @param {TrackParametersType} parameters - track parameters\n * */\n track: (params: TrackParametersType) => Promise<boolean>;\n /**\n * @method getClientConfiguration - get client configuration\n * @param {string} url - url address\n * @param {HeadersType} headers - headers\n * */\n getClientConfiguration: (\n url: string,\n headers: HeadersType,\n ) => Promise<JSONType>;\n /**\n * @method getRemoteData - get data from remote server of Kameleoon\n * @param {string} url - url address\n * */\n getRemoteData: (url: string) => Promise<JSONType>;\n}\n"],"mappings":"sHA4JY,CAAAA,UAAU,CAAAC,OAAA,CAAAD,UAAA,UAAVA,CAAU,QAAV,CAAAA,CAAU,CAAAE,GAAA,OAAVF,CAAU,CAAAG,IAAA,QAAVH,CAAU,MAKVI,YAAY,CAAAH,OAAA,CAAAG,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAC,UAAA,iBAAZD,CAAY,CAAZA,CAAY,CAAAE,SAAA,gBAAZF,CAAY,CAAZA,CAAY,CAAAG,OAAA,cAAZH,CAAY,WAMlB,CAAAI,eAAe,CAAG,CACtB,YAAY,CACZ,YAAY,CACZ,MAAM,CACN,YAAY,CACZ,aAAa,CACb,UAAU,CACV,YAAY,CACJ,CACJC,cAAc,CAAG,CACrB,gBAAgB,CAChB,cAAc,CACd,IAAI,CACJ,OAAO,CACP,SAAS,CACT,aAAa,CACb,MAAM,CACN,QAAQ,CACR,UAAU,CACV,aAAa,CACb,WAAW,CACX,mBAAmB,CACnB,YAAY,CACZ,SAAS,CACT,YAAY,CACZ,KAAK,CACL,cAAc,CACd,gBAAgB,CAChB,UAAU,CACV,aAAa,CACb,cAAc,CACd,yBAAyB,CACzB,YAAY,CACZ,UAAU,CACV,SAAS,CACT,OAAO,CACP,IAAI,CACJ,YAAY,CACZ,YAAY,CACZ,SAAS,CACT,SAAS,CACT,kBAAkB,CAClB,WAAW,CACX,OAAO,CACP,MAAM,CACN,YAAY,CACZ,MAAM,CACN,aAAa,CACb,YAAY,CACZ,QAAQ,CACR,IAAI,CACJ,KAAK,CACG,CACJC,aAAa,CAAG,CAAC,OAAO,CAAE,KAAK,CAAU,CACzCC,UAAU,CAAG,CAAC,KAAK,CAAE,SAAS,CAAE,KAAK,CAAE,QAAQ,CAAU"}
@@ -28,7 +28,7 @@ export type ConsentDataType = {
28
28
  [visitorCode: string]: boolean;
29
29
  };
30
30
  /**
31
- * @type StorageDataType - an enumeration type which represents a data stored on SDK storage
31
+ * @type `StorageDataType` - an enumeration type which represents a data stored on SDK storage
32
32
  *
33
33
  * `string` represents visitor code storage with only one string value
34
34
  * */
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/storage/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { ConfigurationDataType } from 'src/clientConfiguration';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { KameleoonStorageKey } from './constants';\nimport {\n TrackDataParamsType,\n TrackExperimentParamsType,\n} from 'src/requester/types';\n\nexport type ClientDataType = {\n data: ConfigurationDataType;\n lastUpdate: string;\n};\n\nexport type FeatureFlagVariationsType = {\n [experimentId: string]: {\n variationId: number;\n isTargetedRule: boolean;\n isSent: boolean;\n };\n};\n\nexport type VariationDataType = {\n [visitorCode: string]: FeatureFlagVariationsType;\n};\n\ntype OfflineTrackingParameters =\n | TrackDataParamsType\n | TrackExperimentParamsType;\n\nexport type OfflineTracking = {\n requestParameters?: Array<\n OfflineTrackingParameters & { timestamp: number; isExperiment: boolean }\n >;\n};\n\nexport type ConsentDataType = {\n [visitorCode: string]: boolean;\n};\n\n/**\n * @type StorageDataType - an enumeration type which represents a data stored on SDK storage\n *\n * `string` represents visitor code storage with only one string value\n * */\nexport type StorageDataType =\n | ClientDataType\n | VariationDataType\n | OfflineTracking\n | ConsentDataType\n | string;\n\n/**\n * @interface an interface of External Storage which must be implemented to be used as external storage an SDK\n * */\nexport interface IExternalStorage<T = StorageDataType> {\n /**\n * @method read - reads data from the storage\n * @param {string} key - a key, which different SDK data blocks are stored under\n * @returns {T | null} representation of generic Kameleoon data type `T` or `null` if the storage was read successfully but it's empty\n * */\n read: (key: string) => T | null;\n /**\n * @method write - writes data to storage\n * @param {string} key - a key, which different SDK data blocks are stored under\n * @param {T} data - representation of generic Kameleoon data type\n * @returns {void}\n * */\n write: (key: string, data: T) => void;\n}\n\n/**\n * @interface an interface which serves as a wrapper over `IExternalStorage` for internal SDK usage\n * */\nexport interface IStorage<T> {\n readonly key: KameleoonStorageKey;\n read: () => Result<T, KameleoonError>;\n write: (data: T) => Result<void, KameleoonError>;\n update: (data: Partial<T>) => Result<void, KameleoonError>;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/storage/types.ts"],"sourcesContent":["import { Result } from 'ts-res';\nimport { ConfigurationDataType } from 'src/clientConfiguration';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { KameleoonStorageKey } from './constants';\nimport {\n TrackDataParamsType,\n TrackExperimentParamsType,\n} from 'src/requester/types';\n\nexport type ClientDataType = {\n data: ConfigurationDataType;\n lastUpdate: string;\n};\n\nexport type FeatureFlagVariationsType = {\n [experimentId: string]: {\n variationId: number;\n isTargetedRule: boolean;\n isSent: boolean;\n };\n};\n\nexport type VariationDataType = {\n [visitorCode: string]: FeatureFlagVariationsType;\n};\n\ntype OfflineTrackingParameters =\n | TrackDataParamsType\n | TrackExperimentParamsType;\n\nexport type OfflineTracking = {\n requestParameters?: Array<\n OfflineTrackingParameters & { timestamp: number; isExperiment: boolean }\n >;\n};\n\nexport type ConsentDataType = {\n [visitorCode: string]: boolean;\n};\n\n/**\n * @type `StorageDataType` - an enumeration type which represents a data stored on SDK storage\n *\n * `string` represents visitor code storage with only one string value\n * */\nexport type StorageDataType =\n | ClientDataType\n | VariationDataType\n | OfflineTracking\n | ConsentDataType\n | string;\n\n/**\n * @interface an interface of External Storage which must be implemented to be used as external storage an SDK\n * */\nexport interface IExternalStorage<T = StorageDataType> {\n /**\n * @method read - reads data from the storage\n * @param {string} key - a key, which different SDK data blocks are stored under\n * @returns {T | null} representation of generic Kameleoon data type `T` or `null` if the storage was read successfully but it's empty\n * */\n read: (key: string) => T | null;\n /**\n * @method write - writes data to storage\n * @param {string} key - a key, which different SDK data blocks are stored under\n * @param {T} data - representation of generic Kameleoon data type\n * @returns {void}\n * */\n write: (key: string, data: T) => void;\n}\n\n/**\n * @interface an interface which serves as a wrapper over `IExternalStorage` for internal SDK usage\n * */\nexport interface IStorage<T> {\n readonly key: KameleoonStorageKey;\n read: () => Result<T, KameleoonError>;\n write: (data: T) => Result<void, KameleoonError>;\n update: (data: Partial<T>) => Result<void, KameleoonError>;\n}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"pageUrl.js","names":["PageUrl","constructor","a","matchType","url","_defineProperty","conditionValue","evaluate","targetingData","pageViewData","KameleoonData","PageView","Ok","Object","keys","some","checkCondition","MatchType","CONTAINS","includes","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","exports"],"sources":["../../../src/targeting/conditions/pageUrl.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { exhaustCheck, KameleoonError } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class PageUrl implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: string | null;\n\n constructor({ matchType, url }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = url;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const pageViewData = targetingData?.[KameleoonData.PageView];\n\n if (pageViewData) {\n return Ok(\n Object.keys(pageViewData).some((url) => this.checkCondition(url)),\n );\n }\n\n return Ok(false);\n }\n\n private checkCondition(url: string): boolean {\n if (!this.matchType || !this.conditionValue) {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.CONTAINS:\n return url.includes(this.conditionValue);\n case MatchType.EXACT:\n return url === this.conditionValue;\n case MatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(this.conditionValue).test(url);\n default:\n return false;\n }\n }\n}\n"],"mappings":"0uBAOO,KAAM,CAAAA,OAA8B,CAIzCC,WAAWA,CAAAC,CAAA,CAAwC,IAAvC,CAAEC,SAAS,CAATA,CAAS,CAAEC,GAAG,CAAHA,CAAuB,CAAC,CAAAF,CAAA,CAAAG,eAAA,0BAAAA,eAAA,+BAC/C,IAAI,CAACF,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACG,cAAc,CAAGF,CACxB,CAEOG,QAAQA,CAAAL,CAAA,CAEyC,IAFxC,CACdM,aAAa,CAAbA,CACkB,CAAC,CAAAN,CAAA,CACnB,KAAM,CAAAO,CAAY,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,QAAQ,CAAC,CAAC,MAEzD,CAAAF,CAAY,CACP,GAAAG,SAAE,EACPC,MAAM,CAACC,IAAI,CAACL,CAAY,CAAC,CAACM,IAAI,CAAEX,CAAG,EAAK,IAAI,CAACY,cAAc,CAACZ,CAAG,CAAC,CAClE,CAAC,CAGI,GAAAQ,SAAE,IAAM,CACjB,CAEQI,cAAcA,CAACZ,CAAW,CAAW,CAC3C,GAAI,CAAC,IAAI,CAACD,SAAS,EAAI,CAAC,IAAI,CAACG,cAAc,CACzC,SAGF,OAAQ,IAAI,CAACH,SAAS,EACpB,IAAK,CAAAc,gBAAS,CAACC,QAAQ,CACrB,MAAO,CAAAd,CAAG,CAACe,QAAQ,CAAC,IAAI,CAACb,cAAc,CAAC,CAC1C,IAAK,CAAAW,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAAhB,CAAG,GAAK,IAAI,CAACE,cAAc,CACpC,IAAK,CAAAW,gBAAS,CAACI,kBAAkB,CAC/B,MAAO,CAAAC,oBAAS,CAACC,WAAW,CAAC,IAAI,CAACjB,cAAc,CAAC,CAACkB,IAAI,CAACpB,CAAG,CAAC,CAC7D,QACE,QACJ,CACF,CACF,CAACqB,OAAA,CAAAzB,OAAA,CAAAA,OAAA"}
1
+ {"version":3,"file":"pageUrl.js","names":["PageUrl","constructor","a","matchType","url","_defineProperty","conditionValue","evaluate","targetingData","pageViewData","KameleoonData","PageView","Ok","Object","keys","some","checkCondition","MatchType","CONTAINS","includes","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","exports"],"sources":["../../../src/targeting/conditions/pageUrl.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { KameleoonData } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { Utilities } from 'src/utilities';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class PageUrl implements ICondition {\n private matchType?: MatchType | null;\n private conditionValue?: string | null;\n\n constructor({ matchType, url }: ConditionDataType) {\n this.matchType = matchType;\n this.conditionValue = url;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const pageViewData = targetingData?.[KameleoonData.PageView];\n\n if (pageViewData) {\n return Ok(\n Object.keys(pageViewData).some((url) => this.checkCondition(url)),\n );\n }\n\n return Ok(false);\n }\n\n private checkCondition(url: string): boolean {\n if (!this.matchType || !this.conditionValue) {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.CONTAINS:\n return url.includes(this.conditionValue);\n case MatchType.EXACT:\n return url === this.conditionValue;\n case MatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(this.conditionValue).test(url);\n default:\n return false;\n }\n }\n}\n"],"mappings":"0uBAOO,KAAM,CAAAA,OAA8B,CAIzCC,WAAWA,CAAAC,CAAA,CAAwC,IAAvC,CAAEC,SAAS,CAATA,CAAS,CAAEC,GAAG,CAAHA,CAAuB,CAAC,CAAAF,CAAA,CAAAG,eAAA,0BAAAA,eAAA,+BAC/C,IAAI,CAACF,SAAS,CAAGA,CAAS,CAC1B,IAAI,CAACG,cAAc,CAAGF,CACxB,CAEOG,QAAQA,CAAAL,CAAA,CAEyC,IAFxC,CACdM,aAAa,CAAbA,CACkB,CAAC,CAAAN,CAAA,CACnB,KAAM,CAAAO,CAAY,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,QAAQ,CAAC,CAAC,MAEzD,CAAAF,CAAY,CACP,GAAAG,SAAE,EACPC,MAAM,CAACC,IAAI,CAACL,CAAY,CAAC,CAACM,IAAI,CAAEX,CAAG,EAAK,IAAI,CAACY,cAAc,CAACZ,CAAG,CAAC,CAClE,CAAC,CAGI,GAAAQ,SAAE,IAAM,CACjB,CAEQI,cAAcA,CAACZ,CAAW,CAAW,CAC3C,GAAI,CAAC,IAAI,CAACD,SAAS,EAAI,CAAC,IAAI,CAACG,cAAc,CACzC,SAGF,OAAQ,IAAI,CAACH,SAAS,EACpB,IAAK,CAAAc,gBAAS,CAACC,QAAQ,CACrB,MAAO,CAAAd,CAAG,CAACe,QAAQ,CAAC,IAAI,CAACb,cAAc,CAAC,CAC1C,IAAK,CAAAW,gBAAS,CAACG,KAAK,CAClB,MAAO,CAAAhB,CAAG,GAAK,IAAI,CAACE,cAAc,CACpC,IAAK,CAAAW,gBAAS,CAACI,kBAAkB,CAC/B,MAAO,CAAAC,oBAAS,CAACC,WAAW,CAAC,IAAI,CAACjB,cAAc,CAAC,CAACkB,IAAI,CAACpB,CAAG,CAAC,CAC7D,QACE,QACJ,CACF,CACF,CAACqB,OAAA,CAAAzB,OAAA,CAAAA,OAAA"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PreviousPage=void 0;var _tsRes=require("ts-res"),_utilities=require("../../utilities"),_kameleoonData=require("../../kameleoonData"),_types=require("../types");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 PreviousPage{constructor(a){let{matchType:b,url:c}=a;_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"matchType",void 0),this.conditionValue=c,this.matchType=b}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.PageView];if(!c)return(0,_tsRes.Ok)(!1);const d=this.getSecondLatestPageView(Object.values(c));if(!d)return(0,_tsRes.Ok)(!1);const e=d.urlAddress;return(0,_tsRes.Ok)(this.checkCondition(e))}checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types.MatchType.EXACT:return a===this.conditionValue;case _types.MatchType.REGULAR_EXPRESSION:return _utilities.Utilities.parseRegExp(this.conditionValue).test(a);default:return!1}}getSecondLatestPageView(a){if(2>a.length)return;let b,c;return a.forEach(a=>{var d,e;const f=a.timestamps[a.timestamps.length-1],g=a.timestamps[a.timestamps.length-2];if(!b&&!c)return b=a,void(g&&(c=a));const h=null!==(d=b.timestamps[b.timestamps.length-1])&&void 0!==d?d:0;if(f>h){var i,j;c=b,b=a;const d=null===(i=c)||void 0===i?void 0:i.timestamps[(null===(j=c)||void 0===j?void 0:j.timestamps.length)-1];return void(g&&g>d&&(c=a))}let k;if(b.urlAddress===(null===(e=c)||void 0===e?void 0:e.urlAddress))k=c.timestamps[c.timestamps.length-2];else{var l,m,n;k=null!==(l=null===(m=c)||void 0===m?void 0:m.timestamps[(null===(n=c)||void 0===n?void 0:n.timestamps.length)-1])&&void 0!==l?l:0}f&&f>k&&(c=a)}),c}}exports.PreviousPage=PreviousPage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PreviousPage=void 0;var _tsRes=require("ts-res"),_utilities=require("../../utilities"),_kameleoonData=require("../../kameleoonData"),_types=require("../types");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 PreviousPage{constructor(a){let{matchType:b,url:c}=a;_defineProperty(this,"conditionValue",void 0),_defineProperty(this,"matchType",void 0),this.conditionValue=c,this.matchType=b}evaluate(a){let{targetingData:b}=a;const c=null===b||void 0===b?void 0:b[_kameleoonData.KameleoonData.PageView];if(!c)return(0,_tsRes.Ok)(!1);const d=this.getSecondLatestPageView(Object.values(c));if(!d)return(0,_tsRes.Ok)(!1);const e=d.urlAddress;return(0,_tsRes.Ok)(this.checkCondition(e))}checkCondition(a){if(!this.matchType||!this.conditionValue)return!1;switch(this.matchType){case _types.MatchType.CONTAINS:return a.includes(this.conditionValue);case _types.MatchType.EXACT:return a===this.conditionValue;case _types.MatchType.REGULAR_EXPRESSION:return _utilities.Utilities.parseRegExp(this.conditionValue).test(a);default:return!1}}getSecondLatestPageView(a){if(2>a.length)return;let b,c;return a.forEach(a=>{const d=a.timestamps[a.timestamps.length-1];if(!b)return void(b=a);const e=b.timestamps[b.timestamps.length-1];if(d>e)return c=b,void(b=a);const f=c?c.timestamps[c.timestamps.length-1]:0;d>f&&(c=a)}),c}}exports.PreviousPage=PreviousPage;
2
2
  //# sourceMappingURL=previousPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"previousPage.js","names":["PreviousPage","constructor","a","matchType","url","_defineProperty","conditionValue","evaluate","targetingData","pageViewsData","KameleoonData","PageView","Ok","secondLatestPageView","getSecondLatestPageView","Object","values","urlAddress","checkCondition","MatchType","CONTAINS","includes","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","length","latestPV","secondPV","forEach","currentPV","d","e","currentLatestTs","timestamps","currentSecondTs","latestTs","i","j","secondTs","l","m","n","exports"],"sources":["../../../src/targeting/conditions/previousPage.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { Utilities } from 'src/utilities';\nimport { KameleoonData, PageViewDataType } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class PreviousPage implements ICondition {\n private conditionValue?: string | null;\n private matchType?: MatchType | null;\n\n constructor({ matchType, url }: ConditionDataType) {\n this.conditionValue = url;\n this.matchType = matchType;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const pageViewsData = targetingData?.[KameleoonData.PageView];\n\n if (!pageViewsData) {\n return Ok(false);\n }\n\n // --- Note ---\n // There is more concise way to find previous latest page, but it's less performant,\n // here we only ever check two latest timestamps of page and use one loop\n const secondLatestPageView = this.getSecondLatestPageView(\n Object.values(pageViewsData),\n );\n\n if (!secondLatestPageView) {\n return Ok(false);\n }\n\n const url = secondLatestPageView.urlAddress;\n\n return Ok(this.checkCondition(url));\n }\n\n private checkCondition(url: string): boolean {\n if (!this.matchType || !this.conditionValue) {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.CONTAINS:\n return url.includes(this.conditionValue);\n case MatchType.EXACT:\n return url === this.conditionValue;\n case MatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(this.conditionValue).test(url);\n default:\n return false;\n }\n }\n\n private getSecondLatestPageView(\n pageViewsData: PageViewDataType[],\n ): PageViewDataType | undefined {\n if (pageViewsData.length < 2) {\n return undefined;\n }\n\n // --- Note ---\n // Arguments and variables named with abbreviations for better readability\n // `second` in this context is `second to latest`\n let latestPV: PageViewDataType | undefined;\n let secondPV: PageViewDataType | undefined;\n\n pageViewsData.forEach((currentPV) => {\n const currentLatestTs =\n currentPV.timestamps[currentPV.timestamps.length - 1];\n const currentSecondTs =\n currentPV.timestamps[currentPV.timestamps.length - 2];\n\n // -- Initial check\n if (!latestPV && !secondPV) {\n latestPV = currentPV;\n\n if (currentSecondTs) {\n secondPV = currentPV;\n }\n\n return;\n }\n\n const latestTs =\n latestPV!.timestamps[latestPV!.timestamps.length - 1] ?? 0;\n\n // -- Covering a case where latest needs to be updated\n if (currentLatestTs > latestTs) {\n secondPV = latestPV;\n latestPV = currentPV;\n\n const secondTs = secondPV?.timestamps[secondPV?.timestamps.length - 1];\n\n // -- Second may need to be updated after latest\n if (currentSecondTs && currentSecondTs > secondTs!) {\n secondPV = currentPV;\n }\n\n return;\n }\n\n // -- Covering a case where only second needs to be updated\n let secondTs: number;\n\n // -- Second and latest can be the same page\n if (latestPV!.urlAddress === secondPV?.urlAddress) {\n // --- Note ---\n // If latest is equal to second, there are at least two timestamps in array\n secondTs = secondPV.timestamps[secondPV.timestamps.length - 2];\n } else {\n secondTs = secondPV?.timestamps[secondPV?.timestamps.length - 1] ?? 0;\n }\n\n // -- Second may need to be updated\n if (currentLatestTs && currentLatestTs > secondTs!) {\n secondPV = currentPV;\n }\n });\n\n return secondPV;\n }\n}\n"],"mappings":"+uBAOO,KAAM,CAAAA,YAAmC,CAI9CC,WAAWA,CAAAC,CAAA,CAAwC,IAAvC,CAAEC,SAAS,CAATA,CAAS,CAAEC,GAAG,CAAHA,CAAuB,CAAC,CAAAF,CAAA,CAAAG,eAAA,+BAAAA,eAAA,0BAC/C,IAAI,CAACC,cAAc,CAAGF,CAAG,CACzB,IAAI,CAACD,SAAS,CAAGA,CACnB,CAEOI,QAAQA,CAAAL,CAAA,CAEyC,IAFxC,CACdM,aAAa,CAAbA,CACkB,CAAC,CAAAN,CAAA,CACnB,KAAM,CAAAO,CAAa,QAAGD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AAA,CAAUR,UAAU,CAACR,MAAM,EAAG,CAAC,CAAC,YAAAc,CAAA,CAAAA,CAAA,CAAI,CACtE,CAGIP,CAAe,EAAIA,CAAe,CAAGM,CAAS,GAChDX,CAAQ,CAAGE,CAAS,CAExB,CAAC,CAAC,CAEKF,CACT,CACF,CAACe,OAAA,CAAA5C,YAAA,CAAAA,YAAA"}
1
+ {"version":3,"file":"previousPage.js","names":["PreviousPage","constructor","a","matchType","url","_defineProperty","conditionValue","evaluate","targetingData","pageViewsData","KameleoonData","PageView","Ok","secondLatestPageView","getSecondLatestPageView","Object","values","urlAddress","checkCondition","MatchType","CONTAINS","includes","EXACT","REGULAR_EXPRESSION","Utilities","parseRegExp","test","length","latestPV","secondPV","forEach","currentPV","currentLatestTs","timestamps","latestTs","secondTs","exports"],"sources":["../../../src/targeting/conditions/previousPage.ts"],"sourcesContent":["import { Ok, Result } from 'ts-res';\nimport { Utilities } from 'src/utilities';\nimport { KameleoonData, PageViewDataType } from 'src/kameleoonData';\nimport { KameleoonError } from 'src/kameleoonError';\nimport { EvaluationDataType, MatchType } from 'src/targeting/types';\nimport { ConditionDataType, ICondition } from './types';\n\nexport class PreviousPage implements ICondition {\n private conditionValue?: string | null;\n private matchType?: MatchType | null;\n\n constructor({ matchType, url }: ConditionDataType) {\n this.conditionValue = url;\n this.matchType = matchType;\n }\n\n public evaluate({\n targetingData,\n }: EvaluationDataType): Result<boolean, KameleoonError> {\n const pageViewsData = targetingData?.[KameleoonData.PageView];\n\n if (!pageViewsData) {\n return Ok(false);\n }\n\n // --- Note ---\n // There is more concise way to find previous latest page, but it's less performant,\n // here we only ever check two latest timestamps of page and use one loop\n // The second latest can't be equal to the latest\n const secondLatestPageView = this.getSecondLatestPageView(\n Object.values(pageViewsData),\n );\n\n if (!secondLatestPageView) {\n return Ok(false);\n }\n\n const url = secondLatestPageView.urlAddress;\n\n return Ok(this.checkCondition(url));\n }\n\n private checkCondition(url: string): boolean {\n if (!this.matchType || !this.conditionValue) {\n return false;\n }\n\n switch (this.matchType) {\n case MatchType.CONTAINS:\n return url.includes(this.conditionValue);\n case MatchType.EXACT:\n return url === this.conditionValue;\n case MatchType.REGULAR_EXPRESSION:\n return Utilities.parseRegExp(this.conditionValue).test(url);\n default:\n return false;\n }\n }\n\n private getSecondLatestPageView(\n pageViewsData: PageViewDataType[],\n ): PageViewDataType | undefined {\n if (pageViewsData.length < 2) {\n return undefined;\n }\n\n // --- Note ---\n // Arguments and variables named with abbreviations for better readability\n // `second` in this context is `second to latest`\n let latestPV: PageViewDataType | undefined;\n let secondPV: PageViewDataType | undefined;\n\n pageViewsData.forEach((currentPV) => {\n const currentLatestTs =\n currentPV.timestamps[currentPV.timestamps.length - 1];\n\n // -- Initial check\n if (!latestPV) {\n latestPV = currentPV;\n return;\n }\n\n const latestTs = latestPV.timestamps[latestPV!.timestamps.length - 1];\n\n // -- Covering a case where latest needs to be updated\n if (currentLatestTs > latestTs) {\n secondPV = latestPV;\n latestPV = currentPV;\n\n return;\n }\n\n // -- Covering a case where only second needs to be updated\n const secondTs = secondPV\n ? secondPV.timestamps[secondPV.timestamps.length - 1]\n : 0;\n\n // -- Second may need to be updated\n if (currentLatestTs > secondTs) {\n secondPV = currentPV;\n }\n });\n\n return secondPV;\n }\n}\n"],"mappings":"+uBAOO,KAAM,CAAAA,YAAmC,CAI9CC,WAAWA,CAAAC,CAAA,CAAwC,IAAvC,CAAEC,SAAS,CAATA,CAAS,CAAEC,GAAG,CAAHA,CAAuB,CAAC,CAAAF,CAAA,CAAAG,eAAA,+BAAAA,eAAA,0BAC/C,IAAI,CAACC,cAAc,CAAGF,CAAG,CACzB,IAAI,CAACD,SAAS,CAAGA,CACnB,CAEOI,QAAQA,CAAAL,CAAA,CAEyC,IAFxC,CACdM,aAAa,CAAbA,CACkB,CAAC,CAAAN,CAAA,CACnB,KAAM,CAAAO,CAAa,QAAGD,CAAa,WAAbA,CAAa,QAAbA,CAAa,CAAGE,4BAAa,CAACC,QAAQ,CAAC,CA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AAG,CAAQ,CAAGN,CAAQ,CAACK,UAAU,CAACL,CAAQ,CAAEK,UAAU,CAACN,MAAM,CAAG,CAAC,CAAC,CAGrE,GAAIK,CAAe,CAAGE,CAAQ,CAI5B,MAHA,CAAAL,CAAQ,CAAGD,CAAQ,MACnBA,CAAQ,CAAGG,CAAS,EAMtB,KAAM,CAAAI,CAAQ,CAAGN,CAAQ,CACrBA,CAAQ,CAACI,UAAU,CAACJ,CAAQ,CAACI,UAAU,CAACN,MAAM,CAAG,CAAC,CAAC,CACnD,CAAC,CAGDK,CAAe,CAAGG,CAAQ,GAC5BN,CAAQ,CAAGE,CAAS,CAExB,CAAC,CAAC,CAEKF,CACT,CACF,CAACO,OAAA,CAAApC,YAAA,CAAAA,YAAA"}
package/dist/types.d.ts CHANGED
@@ -105,11 +105,11 @@ export type JSONVariableType = {
105
105
  value: JSONType;
106
106
  };
107
107
  /**
108
- * @type FeatureVariableResultType - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
108
+ * @type `FeatureVariableResultType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
109
109
  * */
110
110
  export type FeatureVariableResultType = BooleanVariableType | NumberVariableType | StringVariableType | JSONVariableType;
111
111
  /**
112
- * @type FeatureFlagVariableType - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
112
+ * @type `FeatureFlagVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
113
113
  * */
114
114
  export type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;
115
115
  /**
@@ -149,10 +149,32 @@ export type RemoteVisitorDataParamsType = {
149
149
  filters?: VisitorDataFiltersType;
150
150
  isUniqueIdentifier?: boolean;
151
151
  };
152
+ export type GetFeatureVariablesParamsType = {
153
+ visitorCode: string;
154
+ featureKey: string;
155
+ variationKey: string;
156
+ };
152
157
  export type FeatureFlagType = {
153
158
  id: number;
154
159
  key: string;
155
160
  };
161
+ /**
162
+ * @type `KameleoonVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
163
+ * */
164
+ export type KameleoonVariableType = FeatureVariableResultType;
165
+ /**
166
+ * @type `KameleoonVariationType` - object containing information about the variation and its variables
167
+ * @param {string} key - key of the variation
168
+ * @param {number | null} id - id of the variation or `null` if the visitor hit default variation
169
+ * @param {number | null} experimentId - id of the experiment or `null` if the visitor hit default variation
170
+ * @param {KameleoonVariableType[]} variables - array of variables for the variation
171
+ * */
172
+ export type KameleoonVariationType = {
173
+ key: string;
174
+ id: number | null;
175
+ experimentId: number | null;
176
+ variables: KameleoonVariableType[];
177
+ };
156
178
  /**
157
179
  * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
158
180
  * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["Environment","exports","Production","Staging","Development","VariableType","BOOLEAN","NUMBER","STRING","JSON","Milliseconds","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import { ConfigurationDataType, JSONType } from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSource } from './eventSource';\nimport { IExternalRequestDispatcher } from './requester';\nimport { IExternalStorage } from './storage';\nimport { VisitorDataFiltersType } from './utilities';\nimport { IVisitorCodeManager } from './visitorCodeManager';\n\n/**\n * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute\n * @defaultvalue 60\n *\n * @param {Environment} environment - feature flag environment\n * @defaultvalue Environment.Production\n *\n * @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute\n * Note: if not specified, default value will be used\n * @defaultvalue\n * - JavaScript SDK: `undefined` (no cleanup)\n * - React/React Native SDK: `undefined` (no cleanup)\n * - NodeJS SDK: `30`\n *\n * @param {string | undefined} domain - domain which cookie belongs to\n * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests\n * @defaultvalue `10_000` (10 seconds)\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n requestTimeout?: number;\n domain?: string;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType>} configuration - client's configuration\n * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK\n * */\nexport type SDKCoreParameters = {\n siteCode: string;\n configuration?: Partial<SDKConfigurationType>;\n internalConfiguration: InternalSDKConfigurationType;\n};\n\n/**\n * @param {SdkLanguageType} type - type of the SDK\n * @param {string} version - version of the package\n * */\nexport type ExternalPackageInfoType = {\n type: SdkLanguageType;\n version: string;\n};\n\n/**\n * @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization\n * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation\n * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name\n * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration\n * @param {IExternalRequestDispatcher} externalRequestDispatcher - external request dispatcher, used to track data or get data\n * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code\n * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute\n * */\nexport type InternalSDKConfigurationType = {\n externalStorage: IExternalStorage;\n externalEventSource: IExternalEventSource;\n externalVisitorCodeManager: IVisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequestDispatcher: IExternalRequestDispatcher;\n externalClientConfiguration?: ConfigurationDataType;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field\n * */\nexport enum Environment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of feature variable types\n * */\nexport enum VariableType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n STRING = 'STRING',\n JSON = 'JSON',\n}\n\nexport type BooleanVariableType = {\n key: string;\n type: VariableType.BOOLEAN;\n value: boolean;\n};\n\nexport type NumberVariableType = {\n key: string;\n type: VariableType.NUMBER;\n value: number;\n};\n\nexport type StringVariableType = {\n key: string;\n type: VariableType.STRING;\n value: string;\n};\n\nexport type JSONVariableType = {\n key: string;\n type: VariableType.JSON;\n value: JSONType;\n};\n\n/**\n * @type FeatureVariableResultType - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureVariableResultType =\n | BooleanVariableType\n | NumberVariableType\n | StringVariableType\n | JSONVariableType;\n\n/**\n * @type FeatureFlagVariableType - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;\n\n/**\n * @readonly\n * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.\n * Month is considered in average of 30 days\n * */\nexport enum Milliseconds {\n Second = 1000,\n Minute = 60 * Milliseconds.Second,\n Hour = 60 * Milliseconds.Minute,\n Day = 24 * Milliseconds.Hour,\n Week = 7 * Milliseconds.Day,\n Month = 30 * Milliseconds.Day,\n}\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type TrackConversionParamsType = {\n visitorCode: string;\n goalId: number;\n revenue?: number;\n isUniqueIdentifier?: boolean;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n * @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n isUniqueIdentifier?: boolean;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform\n * @param {string} variableKey - key of the variable to be found for a feature flag with provided `featureKey`, can be found on Kameleoon Platform\n * */\nexport type GetFeatureFlagVariableParamsType = {\n visitorCode: string;\n featureKey: string;\n variableKey: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} customDataIndex - index of the custom data in the warehouse audience\n * @param {string | undefined} warehouseKey - unique key to identify the warehouse data (usually internal user ID)\n * If not specified, the `visitorCode` will be used as a `warehouseKey`\n * */\nexport type GetVisitorWarehouseAudienceParamsType = {\n visitorCode: string;\n customDataIndex: number;\n warehouseKey?: string;\n};\n\nexport type WarehouseAudienceType = {\n // --- Note ---\n // Using `unknown` type here because we don't care about the type of the value\n warehouseAudiences: Record<string, unknown>;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\n};\n\nexport type SetDataCallbackParametersType = {\n visitorCode: string;\n maxAge: number;\n path: string;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * */\nexport type SetUserConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n setData: ({\n visitorCode,\n maxAge,\n path,\n }: SetDataCallbackParametersType) => void;\n};\n"],"mappings":"4IA4EY,CAAAA,WAAW,CAAAC,OAAA,CAAAD,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAE,UAAA,cAAXF,CAAW,CAAAG,OAAA,WAAXH,CAAW,CAAAI,WAAA,eAAXJ,CAAW,MAUXK,YAAY,CAAAJ,OAAA,CAAAI,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAC,OAAA,WAAZD,CAAY,CAAAE,MAAA,UAAZF,CAAY,CAAAG,MAAA,UAAZH,CAAY,CAAAI,IAAA,QAAZJ,CAAY,MAkDZK,YAAY,CAAAT,OAAA,CAAAS,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAC,MAAA,gBAAZD,CAAY,CAAZA,CAAY,CAAAE,MAAA,CAEb,EAAE,CAAGF,CAAY,CAACC,MAAM,WAFvBD,CAAY,CAAZA,CAAY,CAAAG,IAAA,CAGf,EAAE,CAAGH,CAAY,CAACE,MAAM,SAHrBF,CAAY,CAAZA,CAAY,CAAAI,GAAA,CAIhB,EAAE,CAAGJ,CAAY,CAACG,IAAI,QAJlBH,CAAY,CAAZA,CAAY,CAAAK,IAAA,CAKf,CAAC,CAAGL,CAAY,CAACI,GAAG,SALjBJ,CAAY,CAAZA,CAAY,CAAAM,KAAA,CAMd,EAAE,CAAGN,CAAY,CAACI,GAAG,UANnBJ,CAAY"}
1
+ {"version":3,"file":"types.js","names":["Environment","exports","Production","Staging","Development","VariableType","BOOLEAN","NUMBER","STRING","JSON","Milliseconds","Second","Minute","Hour","Day","Week","Month"],"sources":["../src/types.ts"],"sourcesContent":["import { ConfigurationDataType, JSONType } from './clientConfiguration/types';\nimport { SdkLanguageType } from './constants';\nimport { IExternalEventSource } from './eventSource';\nimport { IExternalRequestDispatcher } from './requester';\nimport { IExternalStorage } from './storage';\nimport { VisitorDataFiltersType } from './utilities';\nimport { IVisitorCodeManager } from './visitorCodeManager';\n\n/**\n * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute\n * @defaultvalue 60\n *\n * @param {Environment} environment - feature flag environment\n * @defaultvalue Environment.Production\n *\n * @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute\n * Note: if not specified, default value will be used\n * @defaultvalue\n * - JavaScript SDK: `undefined` (no cleanup)\n * - React/React Native SDK: `undefined` (no cleanup)\n * - NodeJS SDK: `30`\n *\n * @param {string | undefined} domain - domain which cookie belongs to\n * @param {number | undefined} requestTimeout - timeout in _milliseconds_ for requests\n * @defaultvalue `10_000` (10 seconds)\n * */\nexport type SDKConfigurationType = {\n updateInterval?: number;\n environment?: Environment;\n targetingDataCleanupInterval?: number;\n requestTimeout?: number;\n domain?: string;\n};\n\n/**\n * @param {string} siteCode - client's siteCode defined on Kameleoon platform\n * @param {Partial<SDKConfigurationType>} configuration - client's configuration\n * @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK\n * */\nexport type SDKCoreParameters = {\n siteCode: string;\n configuration?: Partial<SDKConfigurationType>;\n internalConfiguration: InternalSDKConfigurationType;\n};\n\n/**\n * @param {SdkLanguageType} type - type of the SDK\n * @param {string} version - version of the package\n * */\nexport type ExternalPackageInfoType = {\n type: SdkLanguageType;\n version: string;\n};\n\n/**\n * @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization\n * @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation\n * @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name\n * @param {ConfigurationDataType} externalClientConfiguration - external fetched client configuration\n * @param {IExternalRequestDispatcher} externalRequestDispatcher - external request dispatcher, used to track data or get data\n * @param {IVisitorCodeManager} externalVisitorCodeManager - external visitor code manager, used to get or generate visitor code\n * @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute\n * */\nexport type InternalSDKConfigurationType = {\n externalStorage: IExternalStorage;\n externalEventSource: IExternalEventSource;\n externalVisitorCodeManager: IVisitorCodeManager;\n externalPackageInfo: ExternalPackageInfoType;\n externalRequestDispatcher: IExternalRequestDispatcher;\n externalClientConfiguration?: ConfigurationDataType;\n};\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field\n * */\nexport enum Environment {\n Production = 'production',\n Staging = 'staging',\n Development = 'development',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum containing all possible variants of feature variable types\n * */\nexport enum VariableType {\n BOOLEAN = 'BOOLEAN',\n NUMBER = 'NUMBER',\n STRING = 'STRING',\n JSON = 'JSON',\n}\n\nexport type BooleanVariableType = {\n key: string;\n type: VariableType.BOOLEAN;\n value: boolean;\n};\n\nexport type NumberVariableType = {\n key: string;\n type: VariableType.NUMBER;\n value: number;\n};\n\nexport type StringVariableType = {\n key: string;\n type: VariableType.STRING;\n value: string;\n};\n\nexport type JSONVariableType = {\n key: string;\n type: VariableType.JSON;\n value: JSONType;\n};\n\n/**\n * @type `FeatureVariableResultType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureVariableResultType =\n | BooleanVariableType\n | NumberVariableType\n | StringVariableType\n | JSONVariableType;\n\n/**\n * @type `FeatureFlagVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type FeatureFlagVariableType = Omit<FeatureVariableResultType, 'key'>;\n\n/**\n * @readonly\n * @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.\n * Month is considered in average of 30 days\n * */\nexport enum Milliseconds {\n Second = 1000,\n Minute = 60 * Milliseconds.Second,\n Hour = 60 * Milliseconds.Minute,\n Day = 24 * Milliseconds.Hour,\n Week = 7 * Milliseconds.Day,\n Month = 30 * Milliseconds.Day,\n}\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {number} goalId - an id of a goal to track\n * @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type TrackConversionParamsType = {\n visitorCode: string;\n goalId: number;\n revenue?: number;\n isUniqueIdentifier?: boolean;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`\n * @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only current and latest previous visits' `customData` is retrieved\n * @param {boolean | undefined} isUniqueIdentifier - an optional parameter for specifying if the visitorCode is a unique identifier, default value is `false`\n * */\nexport type RemoteVisitorDataParamsType = {\n visitorCode: string;\n shouldAddData?: boolean;\n filters?: VisitorDataFiltersType;\n isUniqueIdentifier?: boolean;\n};\n\nexport type GetFeatureVariablesParamsType = {\n visitorCode: string;\n featureKey: string;\n variationKey: string;\n};\n\nexport type FeatureFlagType = {\n id: number;\n key: string;\n};\n\n/**\n * @type `KameleoonVariableType` - tuple of possible feature variable result types, each possible variation is an object containing `key`, `type` and `value` fields, `type` can be checked against `VariableType` enum, if the `type` is `VariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * */\nexport type KameleoonVariableType = FeatureVariableResultType;\n\n/**\n * @type `KameleoonVariationType` - object containing information about the variation and its variables\n * @param {string} key - key of the variation\n * @param {number | null} id - id of the variation or `null` if the visitor hit default variation\n * @param {number | null} experimentId - id of the experiment or `null` if the visitor hit default variation\n * @param {KameleoonVariableType[]} variables - array of variables for the variation\n * */\nexport type KameleoonVariationType = {\n key: string;\n id: number | null;\n experimentId: number | null;\n variables: KameleoonVariableType[];\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {string} featureKey - key of the feature flag to look for, can be found on Kameleoon Platform\n * @param {string} variableKey - key of the variable to be found for a feature flag with provided `featureKey`, can be found on Kameleoon Platform\n * */\nexport type GetFeatureFlagVariableParamsType = {\n visitorCode: string;\n featureKey: string;\n variableKey: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} customDataIndex - index of the custom data in the warehouse audience\n * @param {string | undefined} warehouseKey - unique key to identify the warehouse data (usually internal user ID)\n * If not specified, the `visitorCode` will be used as a `warehouseKey`\n * */\nexport type GetVisitorWarehouseAudienceParamsType = {\n visitorCode: string;\n customDataIndex: number;\n warehouseKey?: string;\n};\n\nexport type WarehouseAudienceType = {\n // --- Note ---\n // Using `unknown` type here because we don't care about the type of the value\n warehouseAudiences: Record<string, unknown>;\n};\n\nexport type TrackingCacheItemType = {\n [experimentId: number]: { variationId: number; expirationTime: number };\n};\n\nexport type SetDataCallbackParametersType = {\n visitorCode: string;\n maxAge: number;\n path: string;\n key: string;\n};\n\n/**\n * @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters\n * @param {boolean} consent - a value representing the legal consent status. - 'true' indicates the\n * visitor has given legal consent. - 'false' indicates the visitor has withdrawn or not\n * provided legal consent.\n * @param {(visitorCode: string) => void} setData - a callback to set a visitor code in cookie\n * */\nexport type SetUserConsentParametersType = {\n visitorCode: string;\n consent: boolean;\n setData: ({\n visitorCode,\n maxAge,\n path,\n }: SetDataCallbackParametersType) => void;\n};\n"],"mappings":"4IA4EY,CAAAA,WAAW,CAAAC,OAAA,CAAAD,WAAA,UAAXA,CAAW,QAAX,CAAAA,CAAW,CAAAE,UAAA,cAAXF,CAAW,CAAAG,OAAA,WAAXH,CAAW,CAAAI,WAAA,eAAXJ,CAAW,MAUXK,YAAY,CAAAJ,OAAA,CAAAI,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAAC,OAAA,WAAZD,CAAY,CAAAE,MAAA,UAAZF,CAAY,CAAAG,MAAA,UAAZH,CAAY,CAAAI,IAAA,QAAZJ,CAAY,MAkDZK,YAAY,CAAAT,OAAA,CAAAS,YAAA,UAAZA,CAAY,QAAZ,CAAAA,CAAY,CAAZA,CAAY,CAAAC,MAAA,gBAAZD,CAAY,CAAZA,CAAY,CAAAE,MAAA,CAEb,EAAE,CAAGF,CAAY,CAACC,MAAM,WAFvBD,CAAY,CAAZA,CAAY,CAAAG,IAAA,CAGf,EAAE,CAAGH,CAAY,CAACE,MAAM,SAHrBF,CAAY,CAAZA,CAAY,CAAAI,GAAA,CAIhB,EAAE,CAAGJ,CAAY,CAACG,IAAI,QAJlBH,CAAY,CAAZA,CAAY,CAAAK,IAAA,CAKf,CAAC,CAAGL,CAAY,CAACI,GAAG,SALjBJ,CAAY,CAAZA,CAAY,CAAAM,KAAA,CAMd,EAAE,CAAGN,CAAY,CAACI,GAAG,UANnBJ,CAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/javascript-sdk-core",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Kameleoon JS SDK Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",