@kameleoon/javascript-sdk-core 2.1.1 → 2.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.
@@ -158,6 +158,13 @@ export interface IKameleoonClient {
158
158
  * - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server
159
159
  */
160
160
  getRemoteData: (key: string) => Promise<JSONType>;
161
+ /**
162
+ * @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
163
+ * See [Kameleoon Automation API](https://developers.kameleoon.com/apis/activation-api-js/api-reference#trigger-1) for the details
164
+ * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
165
+ * @returns {string} Kameleoon tracking code
166
+ */
167
+ getEngineTrackingCode: (visitorCode: string) => string;
161
168
  /**
162
169
  * @method onConfigurationUpdate - fires a callback on client configuration update. Note: this method only works for server sent events of real time update.
163
170
  * @param {() => void} callback - callback function with no parameters that will be called upon configuration update
@@ -199,6 +206,6 @@ export declare class KameleoonClient implements IKameleoonClient {
199
206
  isFeatureFlagActive(visitorCode: string, featureKey: string): boolean;
200
207
  getRemoteData(key: string): Promise<JSONType>;
201
208
  onConfigurationUpdate(callback: () => void): void;
202
- protected _getEngineTrackingCode(visitorCode: string): string;
209
+ getEngineTrackingCode(visitorCode: string): string;
203
210
  private _getFeatureFlagVariation;
204
211
  }
@@ -133,14 +133,12 @@ class KameleoonClient {
133
133
  isUnallocated: false,
134
134
  userAgent
135
135
  }, trackingParameters));
136
- if (this.internalConfiguration.externalPackageInfo.type === _constants.SDKType.NodeJS) {
137
- _utilities.Utilities.updateCache({
138
- cacheManager: this.trackingCache,
139
- visitorCode,
140
- experimentId,
141
- variationId
142
- });
143
- }
136
+ _utilities.Utilities.updateCache({
137
+ cacheManager: this.trackingCache,
138
+ visitorCode,
139
+ experimentId,
140
+ variationId
141
+ });
144
142
  return variationId;
145
143
  }
146
144
  trackConversion({
@@ -332,7 +330,7 @@ class KameleoonClient {
332
330
  }
333
331
  this.campaignConfiguration.onConfigurationUpdate(callback);
334
332
  }
335
- _getEngineTrackingCode(visitorCode) {
333
+ getEngineTrackingCode(visitorCode) {
336
334
  return _utilities.Utilities.getTrackingCode(this.trackingCache, visitorCode);
337
335
  }
338
336
  _getFeatureFlagVariation(visitorCode, featureKey) {
@@ -356,7 +354,7 @@ class KameleoonClient {
356
354
  variationId,
357
355
  rule
358
356
  } = variationData;
359
- if (this.internalConfiguration.externalPackageInfo.type === _constants.SDKType.NodeJS && typeof variationId === 'number' && typeof experimentId === 'number') {
357
+ if (typeof variationId === 'number' && typeof experimentId === 'number') {
360
358
  _utilities.Utilities.updateCache({
361
359
  cacheManager: this.trackingCache,
362
360
  visitorCode,
@@ -1 +1 @@
1
- {"version":3,"file":"kameleoonClient.js","names":["_tsRes","require","_cacheManager","_campaignConfiguration","_clientSettings","_constants","_kameleoonData","_kameleoonError","_requester","_storage","_externalStorage","_utilities","_variationConfiguration","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","KameleoonClient","constructor","siteCode","configuration","internalConfiguration","settings","clientSettings","ClientSettings","externalPackageInfo","externalRequestDispatcher","requester","Requester","environment","packageInfo","requestDispatcher","trackingCache","CacheManager","CACHE_CLEANUP_TIMEOUT","initialize","externalStorage","externalEventSource","externalClientConfiguration","targetingDataCleanupInterval","clientDataStorage","ExternalStorage","KameleoonStorageKey","ClientData","variationDataStorage","VariationData","campaignConfiguration","CampaignConfiguration","storage","targetingCleanupInterval","result","throw","variationConfiguration","VariationConfiguration","experiments","ok","addData","visitorCode","data","Utilities","validateVisitorCode","KameleoonError","KameleoonException","Initialization","addTargetingData","triggerExperiment","experimentId","experiment","find","item","id","ExperimentConfigurationNotFound","targetingData","storedTargetingData","targetingResult","checkTargeting","segment","NotTargeted","dataUrl","getDataUrl","trackingParameters","body","userAgent","getUserAgent","variationId","getAssociatedVariationId","else","error","type","NotAllocated","trackExperiment","UNALLOCATED_VARIATION_ID","isUnallocated","SDKType","NodeJS","updateCache","cacheManager","trackConversion","goalId","revenue","Conversion","flushData","trackData","getExperiments","map","name","getVisitorExperiments","isActive","experimentVariations","getAssignedVariations","experimentVariation","variationResult","getExperimentVariation","getExperimentVariationData","variation","variations","JSON","parse","customJson","err","JSONParse","VariationNotFound","getFeatureFlags","featureFlags","featureKey","getVisitorFeatureFlags","resultFeatureFlags","featureFlag","variationData","getFeatureFlagVariation","variationKey","OFF_VARIATION_KEY","featureFlagId","getFeatureFlagVariationKey","_getFeatureFlagVariation","getFeatureFlagVariable","variableKey","variable","variables","FeatureFlagConfigurationNotFound","featureVariable","parseFeatureVariable","isFeatureFlagActive","getRemoteData","remoteData","onConfigurationUpdate","callback","_getEngineTrackingCode","getTrackingCode","Err","withAssignment","rule","trackRule","featureFlagVariation","Ok","exports"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CacheManager } from './cacheManager';\nimport { CampaignConfiguration, JSONType } from './campaignConfiguration';\nimport { ClientSettings, ClientSettingsType } from './clientSettings';\nimport {\n CACHE_CLEANUP_TIMEOUT,\n OFF_VARIATION_KEY,\n SDKType,\n UNALLOCATED_VARIATION_ID,\n} from './constants';\nimport { Conversion, KameleoonDataType } from './kameleoonData';\nimport { KameleoonError, KameleoonException } from './kameleoonError';\nimport { Requester, TrackExperimentParamsType } from './requester';\nimport {\n ClientDataType,\n KameleoonStorageKey,\n VariationDataType,\n} from './storage';\nimport { ExternalStorage } from './storage/externalStorage';\nimport {\n TrackConversionParamsType,\n ExperimentType,\n FeatureFlagType,\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n InternalSDKConfigurationType,\n SDKCoreParameters,\n TrackingCacheItemType,\n} from './types';\nimport { Utilities } from './utilities';\nimport {\n FeatureFlagVariationType,\n VariationConfiguration,\n} from './variationConfiguration';\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 * @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 */\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.StorageWrite` Couldn't update storage data\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * @method triggerExperiment - triggers experiment by assigning the variation to the user with `visitorCode`, if the variation is already assigned just returns it's id. Note: returned id `0` indicates default variation. At the same time executes `flushData` without sending extra request.\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} experimentId - id of experiment running for the current visitor\n * @returns {number} associated variationId which is successfully searched/assigned\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.ExperimentConfigurationNotFound` No configuration found for provided `experimentId`\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.StorageRead` Couldn't find associated experiment by provided `experimentId` and `visitorCode` inside the storage\n * - `KameleoonException.NotTargeted` Current visitor is not targeted\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n */\n triggerExperiment: (visitorCode: string, experimentId: number) => number;\n /**\n * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flushData`. 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.StorageWrite` Couldn't update storage data\n */\n trackConversion: ({\n visitorCode,\n goalId,\n revenue,\n }: TrackConversionParamsType) => void;\n /**\n * @method flushData - 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\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n */\n flushData: (visitorCode: string) => void;\n /**\n * @method getExperiments - returns a list of experiments stored in the client configuration\n * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n */\n getExperiments: () => ExperimentType[];\n /**\n * @method getVisitorExperiments - returns a list of experiments that the visitor with `visitorCode` is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated if the experiment will be triggered).\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {boolean | undefined} isAllocated - boolean value indicating that only experiments *allocated* for visitor will be returned. Default value is `true`\n * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n */\n getVisitorExperiments: (\n visitorCode: string,\n isAllocated?: boolean,\n ) => ExperimentType[];\n /**\n * @method getExperimentVariationData - returns variation data in JSON format for the variation with `variationId`\n * @param {number} variationId - id of variation\n * @returns {JSONType} variation data in JSON format\n * @throws `KameleoonError` with one of the following `type` s:\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value\n * - `KameleoonException.VariationNotFound` - No variation found for provided `variationId`\n */\n getExperimentVariationData: (variationId: number) => JSONType | null;\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 `initialize` was done for `kameleoonClient`\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.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\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.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `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.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`\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 {FeatureVariableResultType} a variable object containing `type` and `value` fields, `type` can be checked against `FeatureVariableType` enum, if the `type` is `FeatureVariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value\n * - `KameleoonException.NumberParse` - Couldn't pass Number value\n */\n getFeatureFlagVariable: ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType) => 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 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 `initialize` was done for `kameleoonClient`\n */\n onConfigurationUpdate: (callback: () => void) => void;\n}\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 internalConfiguration: InternalSDKConfigurationType;\n private variationConfiguration?: VariationConfiguration;\n private campaignConfiguration?: CampaignConfiguration;\n private settings: ClientSettingsType;\n private trackingCache: CacheManager<TrackingCacheItemType>;\n private requester: Requester;\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 const { externalPackageInfo, externalRequestDispatcher } =\n internalConfiguration;\n const requester = new Requester({\n siteCode,\n environment: clientSettings.environment,\n packageInfo: externalPackageInfo,\n requestDispatcher: externalRequestDispatcher,\n });\n const trackingCache = new CacheManager<TrackingCacheItemType>(\n CACHE_CLEANUP_TIMEOUT,\n );\n\n this.requester = requester;\n this.settings = clientSettings;\n this.trackingCache = trackingCache;\n this.internalConfiguration = internalConfiguration;\n }\n\n public async initialize(): Promise<boolean> {\n const {\n externalStorage,\n externalEventSource,\n externalClientConfiguration,\n targetingDataCleanupInterval,\n } = this.internalConfiguration;\n\n const clientDataStorage = new ExternalStorage<ClientDataType>(\n externalStorage.initialize(KameleoonStorageKey.ClientData),\n );\n const variationDataStorage = new ExternalStorage<VariationDataType>(\n externalStorage.initialize(KameleoonStorageKey.VariationData),\n );\n\n const campaignConfiguration = new CampaignConfiguration({\n settings: this.settings,\n storage: clientDataStorage,\n requester: this.requester,\n externalClientConfiguration,\n targetingCleanupInterval: targetingDataCleanupInterval,\n });\n\n const result = await campaignConfiguration.initialize(externalEventSource);\n result.throw();\n\n const variationConfiguration = new VariationConfiguration(\n campaignConfiguration.experiments,\n variationDataStorage,\n );\n\n this.variationConfiguration = variationConfiguration;\n this.campaignConfiguration = campaignConfiguration;\n\n return result.ok;\n }\n\n public addData(visitorCode: string, ...data: KameleoonDataType[]): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.campaignConfiguration.addTargetingData(visitorCode, ...data).throw();\n }\n\n public triggerExperiment(visitorCode: string, experimentId: number): number {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n if (!this.campaignConfiguration || !this.variationConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const experiment = this.campaignConfiguration.experiments.find(\n (item) => item.id === String(experimentId),\n );\n\n if (!experiment) {\n throw new KameleoonError(\n KameleoonException.ExperimentConfigurationNotFound,\n experimentId,\n visitorCode,\n );\n }\n\n const targetingData =\n this.campaignConfiguration.storedTargetingData[visitorCode];\n\n const targetingResult = Utilities.checkTargeting({\n visitorCode,\n experimentId,\n targetingData,\n segment: experiment.segment,\n variationConfiguration: this.variationConfiguration,\n }).throw();\n\n if (!targetingResult) {\n throw new KameleoonError(KameleoonException.NotTargeted, visitorCode);\n }\n\n const dataUrl = Utilities.getDataUrl(\n visitorCode,\n this.campaignConfiguration,\n );\n\n const trackingParameters: Omit<\n TrackExperimentParamsType,\n 'variationId' | 'isUnallocated'\n > = {\n body: dataUrl,\n visitorCode,\n experimentId,\n };\n\n const userAgent = Utilities.getUserAgent(\n visitorCode,\n this.campaignConfiguration,\n );\n\n const variationId = this.variationConfiguration\n .getAssociatedVariationId(visitorCode, experimentId)\n .else((error) => {\n if (error.type === KameleoonException.NotAllocated) {\n this.requester.trackExperiment({\n variationId: UNALLOCATED_VARIATION_ID,\n isUnallocated: true,\n userAgent,\n ...trackingParameters,\n });\n\n return UNALLOCATED_VARIATION_ID;\n }\n\n throw error;\n });\n\n this.requester.trackExperiment({\n variationId,\n isUnallocated: false,\n userAgent,\n ...trackingParameters,\n });\n\n if (\n this.internalConfiguration.externalPackageInfo.type === SDKType.NodeJS\n ) {\n Utilities.updateCache({\n cacheManager: this.trackingCache,\n visitorCode,\n experimentId,\n variationId,\n });\n }\n\n return variationId;\n }\n\n public trackConversion({\n visitorCode,\n goalId,\n revenue,\n }: TrackConversionParamsType): void {\n this.addData(visitorCode, new Conversion({ goalId, revenue }));\n this.flushData(visitorCode);\n }\n\n public flushData(visitorCode: string): void {\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const dataUrl = Utilities.getDataUrl(\n visitorCode,\n this.campaignConfiguration,\n );\n\n const userAgent = Utilities.getUserAgent(\n visitorCode,\n this.campaignConfiguration,\n );\n\n this.requester.trackData({ visitorCode, body: dataUrl, userAgent });\n }\n\n public getExperiments(): ExperimentType[] {\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n return this.campaignConfiguration.experiments.map(({ id, name }) => ({\n id: Number(id),\n name,\n }));\n }\n\n public getVisitorExperiments(\n visitorCode: string,\n isActive = true,\n ): ExperimentType[] {\n if (!this.variationConfiguration || !this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const experiments = this.campaignConfiguration.experiments;\n const result: ExperimentType[] = [];\n\n const targetingData =\n this.campaignConfiguration.storedTargetingData[visitorCode];\n\n for (const experiment of experiments) {\n const { id, name, segment } = experiment;\n\n const targetingResult = Utilities.checkTargeting({\n targetingData,\n visitorCode,\n segment,\n variationConfiguration: this.variationConfiguration,\n experimentId: Number(id),\n }).throw();\n\n if (!targetingResult) {\n continue;\n }\n\n // -- If `isActive=false` then return every experiment\n if (!isActive) {\n result.push({ id: Number(id), name });\n continue;\n }\n\n // -- Else first check if there are saved variations for the experiment\n // if there is at least one than it's active\n const experimentVariations =\n this.variationConfiguration.getAssignedVariations(visitorCode);\n\n if (experimentVariations.ok) {\n const experimentVariation = experimentVariations.data[experiment.id];\n\n if (experimentVariation) {\n result.push({ id: Number(id), name });\n continue;\n }\n }\n\n // -- Second check if the experiment will have an allocated variation upon triggering\n // if yes than it's active\n const variationResult =\n this.variationConfiguration.getExperimentVariation(\n visitorCode,\n experiment,\n );\n\n if (variationResult.ok) {\n result.push({ id: Number(id), name });\n }\n }\n\n return result;\n }\n\n public getExperimentVariationData(variationId: number): JSONType {\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const experiments = this.campaignConfiguration.experiments;\n\n for (const experiment of experiments) {\n const variation = experiment.variations.find(\n (item) => item.id === String(variationId),\n );\n\n if (variation) {\n try {\n return JSON.parse(variation.customJson);\n } catch (err) {\n throw new KameleoonError(KameleoonException.JSONParse, err);\n }\n }\n }\n\n throw new KameleoonError(KameleoonException.VariationNotFound);\n }\n\n public getFeatureFlags(): FeatureFlagType[] {\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n return this.campaignConfiguration.featureFlags.map(\n ({ id, featureKey }) => ({ id, key: featureKey }),\n );\n }\n\n public getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[] {\n if (!this.variationConfiguration || !this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.campaignConfiguration.featureFlags;\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n const targetingData =\n this.campaignConfiguration.storedTargetingData[visitorCode];\n\n for (const featureFlag of featureFlags) {\n const variationData = this.variationConfiguration\n .getFeatureFlagVariation({\n visitorCode,\n targetingData,\n featureFlag,\n })\n .throw();\n\n if (variationData.variationKey !== OFF_VARIATION_KEY) {\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 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): FeatureVariableResultType {\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n // --- Note ---\n // `_getFeatureFlagVariation` already checks `campaignConfiguration` initialization\n const featureFlags = (this.campaignConfiguration as CampaignConfiguration)\n .featureFlags;\n\n const variable = featureFlags\n .find((item) => item.featureKey === featureKey)\n ?.variations.find((item) => item.key === variationKey)\n ?.variables.find((item) => item.key === variableKey);\n\n if (!variable) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n visitorCode,\n );\n }\n\n const featureVariable = Utilities.parseFeatureVariable(variable).throw();\n\n return featureVariable;\n }\n\n public isFeatureFlagActive(visitorCode: string, featureKey: string): boolean {\n const variationKey = this.getFeatureFlagVariationKey(\n visitorCode,\n featureKey,\n );\n\n return variationKey !== OFF_VARIATION_KEY;\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 onConfigurationUpdate(callback: () => void): void {\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.campaignConfiguration.onConfigurationUpdate(callback);\n }\n\n protected _getEngineTrackingCode(visitorCode: string): string {\n return Utilities.getTrackingCode(this.trackingCache, visitorCode);\n }\n\n private _getFeatureFlagVariation(\n visitorCode: string,\n featureKey: string,\n ): Result<FeatureFlagVariationType, KameleoonError> {\n if (!this.variationConfiguration || !this.campaignConfiguration) {\n return Err(new KameleoonError(KameleoonException.Initialization));\n }\n\n const featureFlags = this.campaignConfiguration.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 visitorCode,\n ),\n );\n }\n\n const targetingData =\n this.campaignConfiguration.storedTargetingData[visitorCode];\n\n const variationData = this.variationConfiguration\n .getFeatureFlagVariation({\n visitorCode,\n featureFlag,\n targetingData,\n withAssignment: true,\n })\n .throw();\n\n const { experimentId, variationId, rule } = variationData;\n\n if (\n this.internalConfiguration.externalPackageInfo.type === SDKType.NodeJS &&\n typeof variationId === 'number' &&\n typeof experimentId === 'number'\n ) {\n Utilities.updateCache({\n cacheManager: this.trackingCache,\n visitorCode,\n experimentId,\n variationId,\n });\n }\n\n const userAgent = Utilities.getUserAgent(\n visitorCode,\n this.campaignConfiguration,\n );\n\n if (rule) {\n Utilities.trackRule({\n visitorCode,\n requester: this.requester,\n featureFlagVariation: variationData,\n campaignConfiguration: this.campaignConfiguration,\n userAgent,\n });\n }\n\n return Ok(variationData);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,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F,oBAAS,CAAC6F,SAAS,CAAC;QAClB/F,WAAW;QACX9B,SAAS,EAAE,IAAI,CAACA,SAAS;QACzB8H,oBAAoB,EAAEzB,aAAa;QACnClF,qBAAqB,EAAE,IAAI,CAACA,qBAAqB;QACjDoC;MACF,CAAC,CAAC;IACJ;IAEA,OAAO,IAAAwE,SAAE,EAAC1B,aAAa,CAAC;EAC1B;AACF;AAAC2B,OAAA,CAAA1I,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"file":"kameleoonClient.js","names":["_tsRes","require","_cacheManager","_campaignConfiguration","_clientSettings","_constants","_kameleoonData","_kameleoonError","_requester","_storage","_externalStorage","_utilities","_variationConfiguration","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","KameleoonClient","constructor","siteCode","configuration","internalConfiguration","settings","clientSettings","ClientSettings","externalPackageInfo","externalRequestDispatcher","requester","Requester","environment","packageInfo","requestDispatcher","trackingCache","CacheManager","CACHE_CLEANUP_TIMEOUT","initialize","externalStorage","externalEventSource","externalClientConfiguration","targetingDataCleanupInterval","clientDataStorage","ExternalStorage","KameleoonStorageKey","ClientData","variationDataStorage","VariationData","campaignConfiguration","CampaignConfiguration","storage","targetingCleanupInterval","result","throw","variationConfiguration","VariationConfiguration","experiments","ok","addData","visitorCode","data","Utilities","validateVisitorCode","KameleoonError","KameleoonException","Initialization","addTargetingData","triggerExperiment","experimentId","experiment","find","item","id","ExperimentConfigurationNotFound","targetingData","storedTargetingData","targetingResult","checkTargeting","segment","NotTargeted","dataUrl","getDataUrl","trackingParameters","body","userAgent","getUserAgent","variationId","getAssociatedVariationId","else","error","type","NotAllocated","trackExperiment","UNALLOCATED_VARIATION_ID","isUnallocated","updateCache","cacheManager","trackConversion","goalId","revenue","Conversion","flushData","trackData","getExperiments","map","name","getVisitorExperiments","isActive","experimentVariations","getAssignedVariations","experimentVariation","variationResult","getExperimentVariation","getExperimentVariationData","variation","variations","JSON","parse","customJson","err","JSONParse","VariationNotFound","getFeatureFlags","featureFlags","featureKey","getVisitorFeatureFlags","resultFeatureFlags","featureFlag","variationData","getFeatureFlagVariation","variationKey","OFF_VARIATION_KEY","featureFlagId","getFeatureFlagVariationKey","_getFeatureFlagVariation","getFeatureFlagVariable","variableKey","variable","variables","FeatureFlagConfigurationNotFound","featureVariable","parseFeatureVariable","isFeatureFlagActive","getRemoteData","remoteData","onConfigurationUpdate","callback","getEngineTrackingCode","getTrackingCode","Err","withAssignment","rule","trackRule","featureFlagVariation","Ok","exports"],"sources":["../src/kameleoonClient.ts"],"sourcesContent":["import { Err, Ok, Result } from 'ts-res';\nimport { CacheManager } from './cacheManager';\nimport { CampaignConfiguration, JSONType } from './campaignConfiguration';\nimport { ClientSettings, ClientSettingsType } from './clientSettings';\nimport {\n CACHE_CLEANUP_TIMEOUT,\n OFF_VARIATION_KEY,\n UNALLOCATED_VARIATION_ID,\n} from './constants';\nimport { Conversion, KameleoonDataType } from './kameleoonData';\nimport { KameleoonError, KameleoonException } from './kameleoonError';\nimport { Requester, TrackExperimentParamsType } from './requester';\nimport {\n ClientDataType,\n KameleoonStorageKey,\n VariationDataType,\n} from './storage';\nimport { ExternalStorage } from './storage/externalStorage';\nimport {\n TrackConversionParamsType,\n ExperimentType,\n FeatureFlagType,\n GetFeatureFlagVariableParamsType,\n FeatureVariableResultType,\n InternalSDKConfigurationType,\n SDKCoreParameters,\n TrackingCacheItemType,\n} from './types';\nimport { Utilities } from './utilities';\nimport {\n FeatureFlagVariationType,\n VariationConfiguration,\n} from './variationConfiguration';\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 * @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 */\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.StorageWrite` Couldn't update storage data\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n */\n addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;\n /**\n * @method triggerExperiment - triggers experiment by assigning the variation to the user with `visitorCode`, if the variation is already assigned just returns it's id. Note: returned id `0` indicates default variation. At the same time executes `flushData` without sending extra request.\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {number} experimentId - id of experiment running for the current visitor\n * @returns {number} associated variationId which is successfully searched/assigned\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.ExperimentConfigurationNotFound` No configuration found for provided `experimentId`\n * - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded\n * - `KameleoonException.StorageRead` Couldn't find associated experiment by provided `experimentId` and `visitorCode` inside the storage\n * - `KameleoonException.NotTargeted` Current visitor is not targeted\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n */\n triggerExperiment: (visitorCode: string, experimentId: number) => number;\n /**\n * @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flushData`. 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.StorageWrite` Couldn't update storage data\n */\n trackConversion: ({\n visitorCode,\n goalId,\n revenue,\n }: TrackConversionParamsType) => void;\n /**\n * @method flushData - 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\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @returns {void}\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n */\n flushData: (visitorCode: string) => void;\n /**\n * @method getExperiments - returns a list of experiments stored in the client configuration\n * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n */\n getExperiments: () => ExperimentType[];\n /**\n * @method getVisitorExperiments - returns a list of experiments that the visitor with `visitorCode` is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated if the experiment will be triggered).\n * @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length\n * @param {boolean | undefined} isAllocated - boolean value indicating that only experiments *allocated* for visitor will be returned. Default value is `true`\n * @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n */\n getVisitorExperiments: (\n visitorCode: string,\n isAllocated?: boolean,\n ) => ExperimentType[];\n /**\n * @method getExperimentVariationData - returns variation data in JSON format for the variation with `variationId`\n * @param {number} variationId - id of variation\n * @returns {JSONType} variation data in JSON format\n * @throws `KameleoonError` with one of the following `type` s:\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value\n * - `KameleoonException.VariationNotFound` - No variation found for provided `variationId`\n */\n getExperimentVariationData: (variationId: number) => JSONType | null;\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 `initialize` was done for `kameleoonClient`\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.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\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.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `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.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`\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 {FeatureVariableResultType} a variable object containing `type` and `value` fields, `type` can be checked against `FeatureVariableType` enum, if the `type` is `FeatureVariableType.BOOLEAN` then the `value` type will be `boolean` and so on.\n * @throws `KameleoonError` with one of the following `type` s:\n *\n * - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded\n * - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`\n * - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`\n * - `KameleoonException.NotTargeted` - Current visitor is not targeted\n * - `KameleoonException.JSONParse` - Couldn't pass JSON value\n * - `KameleoonException.NumberParse` - Couldn't pass Number value\n */\n getFeatureFlagVariable: ({\n visitorCode,\n featureKey,\n variableKey,\n }: GetFeatureFlagVariableParamsType) => 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 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 */\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 `initialize` was done for `kameleoonClient`\n */\n onConfigurationUpdate: (callback: () => void) => void;\n}\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 internalConfiguration: InternalSDKConfigurationType;\n private variationConfiguration?: VariationConfiguration;\n private campaignConfiguration?: CampaignConfiguration;\n private settings: ClientSettingsType;\n private trackingCache: CacheManager<TrackingCacheItemType>;\n private requester: Requester;\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 const { externalPackageInfo, externalRequestDispatcher } =\n internalConfiguration;\n const requester = new Requester({\n siteCode,\n environment: clientSettings.environment,\n packageInfo: externalPackageInfo,\n requestDispatcher: externalRequestDispatcher,\n });\n const trackingCache = new CacheManager<TrackingCacheItemType>(\n CACHE_CLEANUP_TIMEOUT,\n );\n\n this.requester = requester;\n this.settings = clientSettings;\n this.trackingCache = trackingCache;\n this.internalConfiguration = internalConfiguration;\n }\n\n public async initialize(): Promise<boolean> {\n const {\n externalStorage,\n externalEventSource,\n externalClientConfiguration,\n targetingDataCleanupInterval,\n } = this.internalConfiguration;\n\n const clientDataStorage = new ExternalStorage<ClientDataType>(\n externalStorage.initialize(KameleoonStorageKey.ClientData),\n );\n const variationDataStorage = new ExternalStorage<VariationDataType>(\n externalStorage.initialize(KameleoonStorageKey.VariationData),\n );\n\n const campaignConfiguration = new CampaignConfiguration({\n settings: this.settings,\n storage: clientDataStorage,\n requester: this.requester,\n externalClientConfiguration,\n targetingCleanupInterval: targetingDataCleanupInterval,\n });\n\n const result = await campaignConfiguration.initialize(externalEventSource);\n result.throw();\n\n const variationConfiguration = new VariationConfiguration(\n campaignConfiguration.experiments,\n variationDataStorage,\n );\n\n this.variationConfiguration = variationConfiguration;\n this.campaignConfiguration = campaignConfiguration;\n\n return result.ok;\n }\n\n public addData(visitorCode: string, ...data: KameleoonDataType[]): void {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.campaignConfiguration.addTargetingData(visitorCode, ...data).throw();\n }\n\n public triggerExperiment(visitorCode: string, experimentId: number): number {\n Utilities.validateVisitorCode(visitorCode).throw();\n\n if (!this.campaignConfiguration || !this.variationConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const experiment = this.campaignConfiguration.experiments.find(\n (item) => item.id === String(experimentId),\n );\n\n if (!experiment) {\n throw new KameleoonError(\n KameleoonException.ExperimentConfigurationNotFound,\n experimentId,\n visitorCode,\n );\n }\n\n const targetingData =\n this.campaignConfiguration.storedTargetingData[visitorCode];\n\n const targetingResult = Utilities.checkTargeting({\n visitorCode,\n experimentId,\n targetingData,\n segment: experiment.segment,\n variationConfiguration: this.variationConfiguration,\n }).throw();\n\n if (!targetingResult) {\n throw new KameleoonError(KameleoonException.NotTargeted, visitorCode);\n }\n\n const dataUrl = Utilities.getDataUrl(\n visitorCode,\n this.campaignConfiguration,\n );\n\n const trackingParameters: Omit<\n TrackExperimentParamsType,\n 'variationId' | 'isUnallocated'\n > = {\n body: dataUrl,\n visitorCode,\n experimentId,\n };\n\n const userAgent = Utilities.getUserAgent(\n visitorCode,\n this.campaignConfiguration,\n );\n\n const variationId = this.variationConfiguration\n .getAssociatedVariationId(visitorCode, experimentId)\n .else((error) => {\n if (error.type === KameleoonException.NotAllocated) {\n this.requester.trackExperiment({\n variationId: UNALLOCATED_VARIATION_ID,\n isUnallocated: true,\n userAgent,\n ...trackingParameters,\n });\n\n return UNALLOCATED_VARIATION_ID;\n }\n\n throw error;\n });\n\n this.requester.trackExperiment({\n variationId,\n isUnallocated: false,\n userAgent,\n ...trackingParameters,\n });\n\n Utilities.updateCache({\n cacheManager: this.trackingCache,\n visitorCode,\n experimentId,\n variationId,\n });\n\n return variationId;\n }\n\n public trackConversion({\n visitorCode,\n goalId,\n revenue,\n }: TrackConversionParamsType): void {\n this.addData(visitorCode, new Conversion({ goalId, revenue }));\n this.flushData(visitorCode);\n }\n\n public flushData(visitorCode: string): void {\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const dataUrl = Utilities.getDataUrl(\n visitorCode,\n this.campaignConfiguration,\n );\n\n const userAgent = Utilities.getUserAgent(\n visitorCode,\n this.campaignConfiguration,\n );\n\n this.requester.trackData({ visitorCode, body: dataUrl, userAgent });\n }\n\n public getExperiments(): ExperimentType[] {\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n return this.campaignConfiguration.experiments.map(({ id, name }) => ({\n id: Number(id),\n name,\n }));\n }\n\n public getVisitorExperiments(\n visitorCode: string,\n isActive = true,\n ): ExperimentType[] {\n if (!this.variationConfiguration || !this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n Utilities.validateVisitorCode(visitorCode).throw();\n\n const experiments = this.campaignConfiguration.experiments;\n const result: ExperimentType[] = [];\n\n const targetingData =\n this.campaignConfiguration.storedTargetingData[visitorCode];\n\n for (const experiment of experiments) {\n const { id, name, segment } = experiment;\n\n const targetingResult = Utilities.checkTargeting({\n targetingData,\n visitorCode,\n segment,\n variationConfiguration: this.variationConfiguration,\n experimentId: Number(id),\n }).throw();\n\n if (!targetingResult) {\n continue;\n }\n\n // -- If `isActive=false` then return every experiment\n if (!isActive) {\n result.push({ id: Number(id), name });\n continue;\n }\n\n // -- Else first check if there are saved variations for the experiment\n // if there is at least one than it's active\n const experimentVariations =\n this.variationConfiguration.getAssignedVariations(visitorCode);\n\n if (experimentVariations.ok) {\n const experimentVariation = experimentVariations.data[experiment.id];\n\n if (experimentVariation) {\n result.push({ id: Number(id), name });\n continue;\n }\n }\n\n // -- Second check if the experiment will have an allocated variation upon triggering\n // if yes than it's active\n const variationResult =\n this.variationConfiguration.getExperimentVariation(\n visitorCode,\n experiment,\n );\n\n if (variationResult.ok) {\n result.push({ id: Number(id), name });\n }\n }\n\n return result;\n }\n\n public getExperimentVariationData(variationId: number): JSONType {\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const experiments = this.campaignConfiguration.experiments;\n\n for (const experiment of experiments) {\n const variation = experiment.variations.find(\n (item) => item.id === String(variationId),\n );\n\n if (variation) {\n try {\n return JSON.parse(variation.customJson);\n } catch (err) {\n throw new KameleoonError(KameleoonException.JSONParse, err);\n }\n }\n }\n\n throw new KameleoonError(KameleoonException.VariationNotFound);\n }\n\n public getFeatureFlags(): FeatureFlagType[] {\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n return this.campaignConfiguration.featureFlags.map(\n ({ id, featureKey }) => ({ id, key: featureKey }),\n );\n }\n\n public getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[] {\n if (!this.variationConfiguration || !this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n const featureFlags = this.campaignConfiguration.featureFlags;\n const resultFeatureFlags: FeatureFlagType[] = [];\n\n const targetingData =\n this.campaignConfiguration.storedTargetingData[visitorCode];\n\n for (const featureFlag of featureFlags) {\n const variationData = this.variationConfiguration\n .getFeatureFlagVariation({\n visitorCode,\n targetingData,\n featureFlag,\n })\n .throw();\n\n if (variationData.variationKey !== OFF_VARIATION_KEY) {\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 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): FeatureVariableResultType {\n const { variationKey } = this._getFeatureFlagVariation(\n visitorCode,\n featureKey,\n ).throw();\n\n // --- Note ---\n // `_getFeatureFlagVariation` already checks `campaignConfiguration` initialization\n const featureFlags = (this.campaignConfiguration as CampaignConfiguration)\n .featureFlags;\n\n const variable = featureFlags\n .find((item) => item.featureKey === featureKey)\n ?.variations.find((item) => item.key === variationKey)\n ?.variables.find((item) => item.key === variableKey);\n\n if (!variable) {\n throw new KameleoonError(\n KameleoonException.FeatureFlagConfigurationNotFound,\n featureKey,\n visitorCode,\n );\n }\n\n const featureVariable = Utilities.parseFeatureVariable(variable).throw();\n\n return featureVariable;\n }\n\n public isFeatureFlagActive(visitorCode: string, featureKey: string): boolean {\n const variationKey = this.getFeatureFlagVariationKey(\n visitorCode,\n featureKey,\n );\n\n return variationKey !== OFF_VARIATION_KEY;\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 onConfigurationUpdate(callback: () => void): void {\n if (!this.campaignConfiguration) {\n throw new KameleoonError(KameleoonException.Initialization);\n }\n\n this.campaignConfiguration.onConfigurationUpdate(callback);\n }\n\n public getEngineTrackingCode(visitorCode: string): string {\n return Utilities.getTrackingCode(this.trackingCache, visitorCode);\n }\n\n private _getFeatureFlagVariation(\n visitorCode: string,\n featureKey: string,\n ): Result<FeatureFlagVariationType, KameleoonError> {\n if (!this.variationConfiguration || !this.campaignConfiguration) {\n return Err(new KameleoonError(KameleoonException.Initialization));\n }\n\n const featureFlags = this.campaignConfiguration.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 visitorCode,\n ),\n );\n }\n\n const targetingData =\n this.campaignConfiguration.storedTargetingData[visitorCode];\n\n const variationData = this.variationConfiguration\n .getFeatureFlagVariation({\n visitorCode,\n featureFlag,\n targetingData,\n withAssignment: true,\n })\n .throw();\n\n const { experimentId, variationId, rule } = 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 const userAgent = Utilities.getUserAgent(\n visitorCode,\n this.campaignConfiguration,\n );\n\n if (rule) {\n Utilities.trackRule({\n visitorCode,\n requester: this.requester,\n featureFlagVariation: variationData,\n campaignConfiguration: this.campaignConfiguration,\n userAgent,\n });\n }\n\n return Ok(variationData);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAKA,IAAAK,cAA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A,GAAAA,eAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kameleoon/javascript-sdk-core",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "Kameleoon JS SDK Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",