kameleoon-client-javascript
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -1,3 +0,4 @@ | ||
import { ConfigurationInterface, ConfigurationExperimentsInterface, ConfigurationFeatureFlagsInterface, AutomationExperimentInterface, AutomationFeatureFlagInterface } from '../interfaces/interfaces'; | ||
import { ConfigurationInterface, ConfigurationExperimentsInterface, ConfigurationFeatureFlagsInterface, AutomationExperimentInterface, AutomationFeatureFlagInterface, ConfigurationSettings } from '../interfaces/interfaces'; | ||
declare class Configuration implements ConfigurationInterface { | ||
settings: ConfigurationSettings; | ||
updateTime: number; | ||
@@ -8,2 +9,3 @@ experiments: ConfigurationExperimentsInterface; | ||
constructor(siteCode: string, actions: { | ||
configuration: ConfigurationSettings; | ||
experiments: AutomationExperimentInterface[]; | ||
@@ -10,0 +12,0 @@ featureFlags: AutomationFeatureFlagInterface[]; |
@@ -12,2 +12,3 @@ "use strict"; | ||
this.configuration = actions; | ||
this.settings = actions.configuration; | ||
this.experiments = actions.experiments.filter(function (experiment) { return experiment.siteCode == siteCode; }) | ||
@@ -14,0 +15,0 @@ .reduce(function (obj, experiment) { |
@@ -22,3 +22,3 @@ "use strict"; | ||
var respTime = (experiment.respoolTime || []).find(function (resp) { return resp.variationId == variationId; }); | ||
var respoolTimeValue = respTime ? respTime.value : null; | ||
var respoolTimeValue = respTime === null || respTime === void 0 ? void 0 : respTime.value; | ||
var variation = (experiment.variations || []).find(function (variation) { return variation.id == variationId; }); | ||
@@ -33,3 +33,8 @@ var customJsonString = variation ? variation.customJson : null; | ||
} | ||
_this.variationConfigurations[variationId] = new variation_1.default(deviationValue, respoolTimeValue, customJson); | ||
_this.variationConfigurations[variationId] = new variation_1.default({ | ||
id: variationId, | ||
deviation: deviationValue, | ||
respoolTime: respoolTimeValue, | ||
customJson: customJson | ||
}); | ||
}); | ||
@@ -36,0 +41,0 @@ var targetingSegment = void 0; |
@@ -36,3 +36,3 @@ "use strict"; | ||
var respTime = (featureFlag.respoolTime || []).find(function (resp) { return resp.variationId == variationId; }); | ||
var respoolTimeValue = respTime ? respTime.value : null; | ||
var respoolTimeValue = respTime === null || respTime === void 0 ? void 0 : respTime.value; | ||
var variation = (featureFlag.variations || []).find(function (variation) { return variation.id == variationId; }); | ||
@@ -47,3 +47,8 @@ var customJsonString = variation ? variation.customJson : null; | ||
} | ||
_this.variationConfigurations[variationId] = new variation_1.default(deviationValue, respoolTimeValue, customJson); | ||
_this.variationConfigurations[variationId] = new variation_1.default({ | ||
id: variationId, | ||
deviation: deviationValue, | ||
respoolTime: respoolTimeValue, | ||
customJson: customJson | ||
}); | ||
}); | ||
@@ -64,3 +69,3 @@ } | ||
var respTime = (featureFlag.respoolTime || []).find(function (resp) { return resp.variationId == variation.id; }); | ||
var respoolTimeValue = respTime ? respTime.value : null; | ||
var respoolTimeValue = respTime === null || respTime === void 0 ? void 0 : respTime.value; | ||
var customJsonString = variation.customJson; | ||
@@ -74,3 +79,8 @@ var customJson = void 0; | ||
} | ||
_this.variationConfigurations[variation.id] = new variation_1.default(deviation, respoolTimeValue, customJson); | ||
_this.variationConfigurations[variation.id] = new variation_1.default({ | ||
id: variation.id, | ||
deviation: deviation, | ||
respoolTime: respoolTimeValue, | ||
customJson: customJson | ||
}); | ||
} | ||
@@ -77,0 +87,0 @@ }); |
@@ -1,7 +0,15 @@ | ||
declare class Variation { | ||
respoolTime: number | null; | ||
import { CustomJsonType } from "../types"; | ||
export interface VariationInterface { | ||
id: string; | ||
deviation: number; | ||
respoolTime?: number; | ||
customJson?: any; | ||
constructor(deviation: number, respoolTime: number | null, customJson?: any); | ||
} | ||
declare class Variation implements VariationInterface { | ||
id: string; | ||
respoolTime?: number; | ||
deviation: number; | ||
customJson?: CustomJsonType; | ||
constructor({ id, deviation, respoolTime, customJson }: VariationInterface); | ||
} | ||
export default Variation; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Variation = /** @class */ (function () { | ||
function Variation(deviation, respoolTime, customJson) { | ||
function Variation(_a) { | ||
var id = _a.id, deviation = _a.deviation, respoolTime = _a.respoolTime, customJson = _a.customJson; | ||
this.id = id; | ||
this.deviation = deviation; | ||
@@ -6,0 +8,0 @@ this.respoolTime = respoolTime; |
@@ -6,3 +6,2 @@ import { DataInterface } from './interfaces/interfaces'; | ||
nonce: string; | ||
type: string; | ||
constructor(id: number, value: any); | ||
@@ -14,6 +13,13 @@ obtainFullPostTextLine: () => string; | ||
nonce: string; | ||
type: string; | ||
constructor(browser: number); | ||
obtainFullPostTextLine: () => string; | ||
} | ||
export declare enum BrowserType { | ||
Chrome = 0, | ||
InternetExplorer = 1, | ||
Firefox = 2, | ||
Safari = 3, | ||
Opera = 4, | ||
Other = 5 | ||
} | ||
export declare class PageView implements DataInterface { | ||
@@ -24,14 +30,5 @@ url: string; | ||
nonce: string; | ||
type: string; | ||
constructor(url: string, title: string, referrer?: number); | ||
obtainFullPostTextLine: () => string; | ||
} | ||
export declare class Interest implements DataInterface { | ||
index: number; | ||
fresh: boolean; | ||
nonce: string; | ||
type: string; | ||
constructor(index: number); | ||
obtainFullPostTextLine: () => string; | ||
} | ||
export declare class Conversion implements DataInterface { | ||
@@ -42,6 +39,16 @@ goalId: number; | ||
nonce: string; | ||
type: string; | ||
constructor(goalId: number, revenue?: number, negative?: boolean); | ||
obtainFullPostTextLine: () => string; | ||
} | ||
export declare class Device implements DataInterface { | ||
device: DeviceType; | ||
nonce: string; | ||
constructor(device: DeviceType); | ||
obtainFullPostTextLine: () => string; | ||
} | ||
export declare enum DeviceType { | ||
Phone = "PHONE", | ||
Tablet = "TABLET", | ||
Desktop = "DESKTOP" | ||
} | ||
declare const _default: { | ||
@@ -59,5 +66,7 @@ browsers: { | ||
Browser: typeof Browser; | ||
BrowserType: typeof BrowserType; | ||
PageView: typeof PageView; | ||
Interest: typeof Interest; | ||
Device: typeof Device; | ||
DeviceType: typeof DeviceType; | ||
}; | ||
export default _default; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Conversion = exports.Interest = exports.PageView = exports.Browser = exports.CustomData = void 0; | ||
var nonce_1 = __importDefault(require("./nonce")); | ||
exports.DeviceType = exports.Device = exports.Conversion = exports.PageView = exports.BrowserType = exports.Browser = exports.CustomData = void 0; | ||
var nonce_1 = require("./nonce"); | ||
var CustomData = /** @class */ (function () { | ||
function CustomData(id, value) { | ||
var _this = this; | ||
this.type = "CustomData"; | ||
this.obtainFullPostTextLine = function () { | ||
@@ -18,3 +14,3 @@ var encodedValue = encodeURIComponent(JSON.stringify([[_this.value, 1]])); | ||
this.value = value; | ||
this.nonce = (0, nonce_1.default)(); | ||
this.nonce = (0, nonce_1.obtainNonce)(); | ||
} | ||
@@ -27,3 +23,2 @@ return CustomData; | ||
var _this = this; | ||
this.type = "Browser"; | ||
this.obtainFullPostTextLine = function () { | ||
@@ -36,3 +31,3 @@ if (_this.browser < 0) { | ||
this.browser = browser; | ||
this.nonce = (0, nonce_1.default)(); | ||
this.nonce = (0, nonce_1.obtainNonce)(); | ||
} | ||
@@ -42,6 +37,14 @@ return Browser; | ||
exports.Browser = Browser; | ||
var BrowserType; | ||
(function (BrowserType) { | ||
BrowserType[BrowserType["Chrome"] = 0] = "Chrome"; | ||
BrowserType[BrowserType["InternetExplorer"] = 1] = "InternetExplorer"; | ||
BrowserType[BrowserType["Firefox"] = 2] = "Firefox"; | ||
BrowserType[BrowserType["Safari"] = 3] = "Safari"; | ||
BrowserType[BrowserType["Opera"] = 4] = "Opera"; | ||
BrowserType[BrowserType["Other"] = 5] = "Other"; | ||
})(BrowserType = exports.BrowserType || (exports.BrowserType = {})); | ||
var PageView = /** @class */ (function () { | ||
function PageView(url, title, referrer) { | ||
var _this = this; | ||
this.type = "PageView"; | ||
this.obtainFullPostTextLine = function () { | ||
@@ -53,3 +56,3 @@ return "eventType=page&href=" + encodeURIComponent(_this.url) + "&title=" + _this.title + "&keyPages=[]" + (_this.referrer == null ? "" : "&referrers=[" + _this.referrer + "]") + "&nonce=" + _this.nonce; | ||
this.referrer = referrer; | ||
this.nonce = (0, nonce_1.default)(); | ||
this.nonce = (0, nonce_1.obtainNonce)(); | ||
} | ||
@@ -59,16 +62,2 @@ return PageView; | ||
exports.PageView = PageView; | ||
var Interest = /** @class */ (function () { | ||
function Interest(index) { | ||
var _this = this; | ||
this.fresh = true; | ||
this.type = "Interest"; | ||
this.obtainFullPostTextLine = function () { | ||
return "eventType=interests&indexes=[" + _this.index + "]&fresh=" + _this.fresh.toString() + "&nonce=" + _this.nonce; | ||
}; | ||
this.index = index; | ||
this.nonce = (0, nonce_1.default)(); | ||
} | ||
return Interest; | ||
}()); | ||
exports.Interest = Interest; | ||
var Conversion = /** @class */ (function () { | ||
@@ -79,3 +68,2 @@ function Conversion(goalId, revenue, negative) { | ||
if (negative === void 0) { negative = false; } | ||
this.type = "Conversion"; | ||
this.obtainFullPostTextLine = function () { | ||
@@ -87,3 +75,3 @@ return "eventType=conversion&goalId=" + _this.goalId.toString() + "&revenue=" + _this.revenue.toString() + "&negative=" + _this.negative.toString() + "&nonce=" + _this.nonce; | ||
this.negative = negative; | ||
this.nonce = (0, nonce_1.default)(); | ||
this.nonce = (0, nonce_1.obtainNonce)(); | ||
} | ||
@@ -93,2 +81,20 @@ return Conversion; | ||
exports.Conversion = Conversion; | ||
var Device = /** @class */ (function () { | ||
function Device(device) { | ||
var _this = this; | ||
this.obtainFullPostTextLine = function () { | ||
return "eventType=staticData&deviceType=" + _this.device + "&nonce=" + _this.nonce; | ||
}; | ||
this.device = device; | ||
this.nonce = (0, nonce_1.obtainNonce)(); | ||
} | ||
return Device; | ||
}()); | ||
exports.Device = Device; | ||
var DeviceType; | ||
(function (DeviceType) { | ||
DeviceType["Phone"] = "PHONE"; | ||
DeviceType["Tablet"] = "TABLET"; | ||
DeviceType["Desktop"] = "DESKTOP"; | ||
})(DeviceType = exports.DeviceType || (exports.DeviceType = {})); | ||
exports.default = { | ||
@@ -99,4 +105,6 @@ browsers: { "CHROME": 0, "INTERNET_EXPLORER": 1, "FIREFOX": 2, "SAFARI": 3, "OPERA": 4, "OTHER": 5 }, | ||
Browser: Browser, | ||
BrowserType: BrowserType, | ||
PageView: PageView, | ||
Interest: Interest | ||
Device: Device, | ||
DeviceType: DeviceType | ||
}; |
@@ -51,2 +51,3 @@ /// <reference types="node" /> | ||
export interface ConfigurationInterface { | ||
settings: ConfigurationSettings; | ||
updateTime: number; | ||
@@ -62,2 +63,5 @@ experiments: ConfigurationExperimentsInterface; | ||
} | ||
export interface ConfigurationSettings { | ||
realTimeUpdate: boolean; | ||
} | ||
export interface CallbackInterface { | ||
@@ -70,3 +74,2 @@ success: () => void; | ||
obtainFullPostTextLine: () => string; | ||
type: string; | ||
} | ||
@@ -73,0 +76,0 @@ export interface ConditionsInterface { |
import Configuration from './configurations/configuration'; | ||
import Data from "./data"; | ||
import TargetingData from "./targeting/targetingData"; | ||
import TargetingTree from "./targeting/targetingTree"; | ||
import TargetingCondition from "./targeting/targetingCondition"; | ||
import Experiment from "./configurations/experiment"; | ||
@@ -16,7 +14,2 @@ import FeatureFlag from "./configurations/featureFlag"; | ||
declare class KameleoonClient { | ||
static readonly DEFAULT_MILLISECONDS_BETWEEN_TARGETING_DATA_UPDATE = 1800000; | ||
static readonly MINUTES_SESSION_DURATION: number; | ||
static readonly TARGETING_DATA_MAXIMUM_SIZE_BYTES = 500; | ||
static readonly API_SSX_URL = "https://api-ssx.kameleoon.com/"; | ||
static readonly API_DATA_URL = "https://api-data.kameleoon.com/"; | ||
static readonly VISITOR_CODE_MAX_LENGTH = 255; | ||
@@ -36,5 +29,8 @@ configurations?: Configuration; | ||
visitorDataMaximumSize: number; | ||
environment: string; | ||
environment: string | null; | ||
private realTimeConfigurationService; | ||
private handlerUpdateConfiguration; | ||
private variationStorage; | ||
constructor(siteCode: string, configuration?: SDKConfiguration); | ||
private updateConfiguration; | ||
private updateCampaignConfiguration; | ||
runWhenReady: (successCallback: () => void, errorCallback: () => void, timeout: number) => void; | ||
@@ -44,3 +40,3 @@ clearCallbacks: (success: boolean, errorCallback?: (() => void) | undefined) => void; | ||
flush: (visitorCode?: string | undefined) => void; | ||
triggerExperiment: (visitorCode: string, experimentId: number, timeout?: any) => number; | ||
triggerExperiment: (visitorCode: string, experimentId: number) => number; | ||
activateFeature: (visitorCode: string, featureIdOrName: number | string) => boolean; | ||
@@ -53,2 +49,3 @@ generateRandomString: () => string; | ||
private getAPIDataRequestURL; | ||
private getEventsRequestURL; | ||
getExperimentRegisterURL: (visitorCode: string, experimentId: number, variationId?: number | undefined, noneVariation?: boolean | undefined) => string; | ||
@@ -61,10 +58,33 @@ getUnsentUsers: () => string[]; | ||
addData: (visitorCode: string, ...data: DataInterface[]) => void; | ||
checkTargeting: (visitorCode: string, containerID: number, isFF: boolean) => boolean | null; | ||
checkTargetingTree: (visitorCode: string, targetingTree?: TargetingTree | undefined) => boolean | null; | ||
checkTargetingCondition: (visitorCode: string, targetingCondition: TargetingCondition) => boolean; | ||
obtainVariationAssociatedData: (variationId: number) => any; | ||
checkTargeting: (visitorCode: string, campaignId: number, isFF: boolean) => boolean | null; | ||
private getConditionData; | ||
obtainVariationAssociatedData: (variationId: number) => Record<string | number | symbol, string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | (string | number | boolean | { | ||
[x: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any)[])[])[])[])[])[])[])[])[])[])[]; | ||
} | any)[])[])[])[])[])[])[])[])[])[])[]>; | ||
obtainFeatureVariable: (featureIdOrName: number | string, variable: string) => any; | ||
retrieveDataFromRemoteSource: (key: string) => Promise<any>; | ||
private _parseJsonValue; | ||
save: () => void; | ||
private saveConfiguration; | ||
private validateVisitorCode; | ||
@@ -74,2 +94,5 @@ private checkSiteEnabled; | ||
private getAndClearUnsentData; | ||
onUpdateConfiguration: (handler: () => void) => void; | ||
private manageConfiguraitonUpdate; | ||
private fireUpdateConfigurationHandler; | ||
} | ||
@@ -76,0 +99,0 @@ declare const KameleoonException: { |
@@ -66,3 +66,2 @@ "use strict"; | ||
var kameleoonUtils_1 = __importStar(require("./kameleoonUtils")); | ||
var nonce_1 = __importDefault(require("./nonce")); | ||
var targetingData_1 = __importDefault(require("./targeting/targetingData")); | ||
@@ -77,2 +76,7 @@ var experimentConfigurationNotFound_1 = __importDefault(require("./exceptions/experimentConfigurationNotFound")); | ||
var siteCodeDisabled_1 = require("./exceptions/siteCodeDisabled"); | ||
var nonce_1 = require("./nonce"); | ||
var realTimeConfigurationService_1 = require("./realTimeConfigurationService"); | ||
var variationStorage_1 = require("./storage/variationStorage"); | ||
var constants_1 = require("./constants"); | ||
var targetingEngine_1 = require("./targeting/targetingEngine"); | ||
var KameleoonClient = /** @class */ (function () { | ||
@@ -87,4 +91,8 @@ function KameleoonClient(siteCode, configuration) { | ||
this.visitorDataMaximumSize = 1; | ||
this.environment = "production"; | ||
this.updateConfiguration = function () { | ||
this.environment = null; | ||
this.realTimeConfigurationService = null; | ||
this.handlerUpdateConfiguration = null; | ||
this.variationStorage = new variationStorage_1.VariationStorage(); | ||
this.updateCampaignConfiguration = function (timeStamp) { | ||
var _a; | ||
var data = localStorage.kameleoonJavaScriptClientData; | ||
@@ -117,3 +125,3 @@ if (data) { | ||
var needUpdate = false; | ||
if (!savedConfiguration) { | ||
if (!savedConfiguration || timeStamp != null) { // timeStamp != null means update by SSE event and requires force update | ||
needUpdate = true; | ||
@@ -124,2 +132,3 @@ } | ||
var parsedConfiguration = new configuration_1.default(_this.siteCode, { | ||
configuration: savedConfiguration.configuration, | ||
experiments: savedConfiguration.experiments, | ||
@@ -129,3 +138,4 @@ featureFlags: savedConfiguration.featureFlags, | ||
}); | ||
if (parsedConfiguration.updateTime < new Date().getTime() - (_this.minutesBetweenConfigurationUpdate * 1000 * 60)) { | ||
if (parsedConfiguration.updateTime < new Date().getTime() - (_this.minutesBetweenConfigurationUpdate * 1000 * 60) || //refresh by polling interval | ||
parsedConfiguration.settings.realTimeUpdate) { //streaming initial refresh, need to update to recent version of configuration | ||
needUpdate = true; | ||
@@ -142,3 +152,7 @@ } | ||
if (needUpdate) { | ||
kameleoonUtils_1.default.doRequest("https://customers.kameleoon.com/mobile/configuration?siteCode=".concat(_this.siteCode, "&environment=").concat(_this.environment), kameleoonUtils_1.HttpMethod.GET, null, function (response) { | ||
var siteCodeStringUrl = "mobile?siteCode=".concat(_this.siteCode); | ||
var environmentStringUrl = ((_a = _this.environment) === null || _a === void 0 ? void 0 : _a.length) ? "&environment=".concat(_this.environment) : ''; | ||
var timeStampStringUrl = timeStamp ? "&ts=".concat(timeStamp) : ""; | ||
var configurationUrl = constants_1.CONFIGURATION_URL + siteCodeStringUrl + environmentStringUrl + timeStampStringUrl; | ||
kameleoonUtils_1.default.doRequest(configurationUrl, kameleoonUtils_1.HttpMethod.GET, null, function (response) { | ||
try { | ||
@@ -148,3 +162,5 @@ _this.configurations = new configuration_1.default(_this.siteCode, JSON.parse(response)); | ||
_this.clearCallbacks(true); | ||
_this.save(); | ||
_this.saveConfiguration(); | ||
_this.fireUpdateConfigurationHandler(Boolean(timeStamp)); //fire handler after configuration was updated with SSE event | ||
_this.manageConfiguraitonUpdate(_this.configurations.settings.realTimeUpdate); | ||
} | ||
@@ -154,3 +170,3 @@ catch (e) { | ||
} | ||
}); | ||
}, false); | ||
} | ||
@@ -202,3 +218,3 @@ else { | ||
var body = _this.getAndClearUnsentData(visitorCode); | ||
kameleoonUtils_1.default.doRequest(KameleoonClient.API_SSX_URL + _this.getDataTrackingURL(visitorCode), kameleoonUtils_1.HttpMethod.POST, body, null); | ||
kameleoonUtils_1.default.doRequest(constants_1.API_SSX_URL + _this.getDataTrackingURL(visitorCode), kameleoonUtils_1.HttpMethod.POST, body, null); | ||
} | ||
@@ -209,3 +225,3 @@ else { | ||
}; | ||
this.triggerExperiment = function (visitorCode, experimentId, timeout) { | ||
this.triggerExperiment = function (visitorCode, experimentId) { | ||
var _a; | ||
@@ -218,20 +234,28 @@ _this.validateVisitorCode(visitorCode); | ||
var noneVariation = true; | ||
if (xpConf != null) { | ||
var hashDouble = _this.obtainHashDouble(experimentId, visitorCode, xpConf); | ||
var total = 0.0; | ||
for (var key in xpConf.variationConfigurations) { | ||
var variationConfiguration = xpConf.variationConfigurations[key]; | ||
total += variationConfiguration.deviation; | ||
if (total >= hashDouble) { | ||
noneVariation = false; | ||
variationId = parseInt(key); | ||
break; | ||
var savedVariationId = _this.variationStorage.getVariationId(visitorCode, experimentId); | ||
if (savedVariationId) { | ||
variationId = savedVariationId; | ||
noneVariation = false; | ||
} | ||
else { | ||
if (xpConf) { | ||
var hashDouble = _this.obtainHashDouble(experimentId, visitorCode, xpConf); | ||
var total = 0.0; | ||
for (var key in xpConf.variationConfigurations) { | ||
var variationConfiguration = xpConf.variationConfigurations[key]; | ||
total += variationConfiguration.deviation; | ||
if (total >= hashDouble) { | ||
noneVariation = false; | ||
variationId = parseInt(key); | ||
_this.variationStorage.updateVariation(visitorCode, experimentId, variationConfiguration); | ||
break; | ||
} | ||
} | ||
var body = _this.getAndClearUnsentData(visitorCode); | ||
kameleoonUtils_1.default.doRequest(constants_1.API_SSX_URL + _this.getExperimentRegisterURL(visitorCode, experimentId, variationId, noneVariation), kameleoonUtils_1.HttpMethod.POST, body); | ||
} | ||
var body = _this.getAndClearUnsentData(visitorCode); | ||
kameleoonUtils_1.default.doRequest(KameleoonClient.API_SSX_URL + _this.getExperimentRegisterURL(visitorCode, experimentId, variationId, noneVariation), kameleoonUtils_1.HttpMethod.POST, body); | ||
else { | ||
throw new experimentConfigurationNotFound_1.default("KameleoonException.ExperimentConfigurationNotFound"); | ||
} | ||
} | ||
else { | ||
throw new experimentConfigurationNotFound_1.default("KameleoonException.ExperimentConfigurationNotFound"); | ||
} | ||
if (noneVariation) { | ||
@@ -278,3 +302,3 @@ throw new notActivated_1.default("KameleoonException.NotActivated"); | ||
var body = _this.getAndClearUnsentData(visitorCode); | ||
kameleoonUtils_1.default.doRequest(KameleoonClient.API_SSX_URL + _this.getExperimentRegisterURL(visitorCode, featureId, variationId, noneVariation), kameleoonUtils_1.HttpMethod.POST, body); | ||
kameleoonUtils_1.default.doRequest(constants_1.API_SSX_URL + _this.getExperimentRegisterURL(visitorCode, featureId, variationId, noneVariation), kameleoonUtils_1.HttpMethod.POST, body); | ||
result = variationId != 0; | ||
@@ -334,3 +358,3 @@ } | ||
this.getCommonSSXParameters = function (visitorCode) { | ||
return "&nonce=" + (0, nonce_1.default)() + "&siteCode=" + _this.siteCode + "&visitorCode=" + visitorCode; | ||
return "&nonce=" + (0, nonce_1.obtainNonce)() + "&siteCode=" + _this.siteCode + "&visitorCode=" + visitorCode; | ||
}; | ||
@@ -341,4 +365,7 @@ this.getDataTrackingURL = function (visitorCode) { | ||
this.getAPIDataRequestURL = function (key) { | ||
return KameleoonClient.API_DATA_URL + "data?siteCode=".concat(_this.siteCode, "&key=").concat(key); | ||
return "".concat(constants_1.API_DATA_URL, "data?siteCode=").concat(_this.siteCode, "&key=").concat(key); | ||
}; | ||
this.getEventsRequestURL = function (siteCode) { | ||
return "".concat(constants_1.EVENTS_URL, "sse?siteCode=").concat(siteCode); | ||
}; | ||
this.getExperimentRegisterURL = function (visitorCode, experimentId, variationId, noneVariation) { | ||
@@ -375,3 +402,3 @@ var baseURL = "experimentTracking?" + _this.getCommonSSXParameters(visitorCode) + "&experimentId=" + experimentId; | ||
_this.targetingData[visitorCode] = _this.targetingData[visitorCode].reduce(function (arr, data) { | ||
if (data.lastActivityTime + KameleoonClient.MINUTES_SESSION_DURATION > currentTime) { | ||
if (data.lastActivityTime + constants_1.MINUTES_SESSION_DURATION > currentTime) { | ||
arr.push(data); | ||
@@ -382,3 +409,3 @@ } | ||
} | ||
_this.save(); | ||
_this.saveConfiguration(); | ||
}; | ||
@@ -402,3 +429,3 @@ this.addData = function (visitorCode) { | ||
} | ||
_this.save(); | ||
_this.saveConfiguration(); | ||
}); | ||
@@ -408,3 +435,3 @@ }; | ||
// check targeting | ||
this.checkTargeting = function (visitorCode, containerID, isFF) { | ||
this.checkTargeting = function (visitorCode, campaignId, isFF) { | ||
var _a, _b; | ||
@@ -415,6 +442,6 @@ var targeting = true; | ||
if (isFF) { | ||
xpConf = (_a = _this.configurations) === null || _a === void 0 ? void 0 : _a.featureFlags[containerID]; | ||
xpConf = (_a = _this.configurations) === null || _a === void 0 ? void 0 : _a.featureFlags[campaignId]; | ||
} | ||
else { | ||
xpConf = (_b = _this.configurations) === null || _b === void 0 ? void 0 : _b.experiments[containerID]; | ||
xpConf = (_b = _this.configurations) === null || _b === void 0 ? void 0 : _b.experiments[campaignId]; | ||
} | ||
@@ -432,3 +459,3 @@ if (xpConf != null) { | ||
// obtaining targeting checking result and assigning targeting to container | ||
targeting = _this.checkTargetingTree(visitorCode, targetingTree); | ||
targeting = targetingEngine_1.TargetingEngine.checkTargetingTree(targetingTree, function (type) { return _this.getConditionData(type, visitorCode, campaignId); }); | ||
} | ||
@@ -438,127 +465,21 @@ } | ||
}; | ||
// check targeting tree | ||
this.checkTargetingTree = function (visitorCode, targetingTree) { | ||
var result = null; | ||
// checking if the tree has no targeting condition | ||
if (null == targetingTree) { | ||
result = true; | ||
this.getConditionData = function (type, visitorCode, campaignId) { | ||
switch (type) { | ||
case constants_1.ConditionTypes.CUSTOM_DATUM: | ||
return { targetingData: _this.getTargetingData(visitorCode) }; | ||
case constants_1.ConditionTypes.EXCLUSIVE_EXPERIMENT: | ||
return { currentExperimentId: campaignId, | ||
variationStorage: _this.variationStorage.getMapVariationId(visitorCode) }; | ||
case constants_1.ConditionTypes.TARGET_EXPERIMENT: | ||
return { variationStorage: _this.variationStorage.getMapVariationId(visitorCode) }; | ||
default: | ||
return null; | ||
} | ||
else { | ||
// checking if the tree is a leaf | ||
var targetingCondition = targetingTree.targetingCondition; | ||
if (null != targetingCondition) { | ||
result = _this.checkTargetingCondition(visitorCode, targetingCondition); | ||
} | ||
else { | ||
// computing left child result | ||
var leftChildResult = _this.checkTargetingTree(visitorCode, targetingTree.leftChild); | ||
var mustComputeRightChildResult = false; | ||
if (true == leftChildResult) { | ||
if (!targetingTree.orOperator) { | ||
mustComputeRightChildResult = true; // true AND anything, needs to know the anything | ||
} | ||
} | ||
else if (false == leftChildResult) { | ||
if (targetingTree.orOperator) { | ||
mustComputeRightChildResult = true; // false OR anything, needs to know the anything | ||
} | ||
} | ||
else if (null == leftChildResult) { | ||
mustComputeRightChildResult = true; // (undefined OR anything) or (undefined AND anything), needs to know the anything | ||
} | ||
// computing right child result if we must do it | ||
var rightChildResult = null; | ||
if (mustComputeRightChildResult) { | ||
rightChildResult = _this.checkTargetingTree(visitorCode, targetingTree.rightChild); | ||
} | ||
// computing result | ||
if (true == leftChildResult) { | ||
if (targetingTree.orOperator) { | ||
result = true; // true OR anything | ||
} | ||
else { | ||
if (true == rightChildResult) { | ||
result = true; // true AND true | ||
} | ||
else if (false == rightChildResult) { | ||
result = false; // true AND false | ||
} | ||
else if (null == rightChildResult) { | ||
result = null; // true AND undefined | ||
} | ||
} | ||
} | ||
else if (false == leftChildResult) { | ||
if (targetingTree.orOperator) { | ||
if (true == rightChildResult) { | ||
result = true; // false OR true | ||
} | ||
else if (false == rightChildResult) { | ||
result = false; // false OR false | ||
} | ||
else if (null == rightChildResult) { | ||
result = null; // false OR undefined | ||
} | ||
} | ||
else { | ||
result = false; // false AND anything | ||
} | ||
} | ||
else if (null == leftChildResult) { | ||
if (targetingTree.orOperator) { | ||
if (true == rightChildResult) { | ||
result = true; // undefined OR true | ||
} | ||
else if (false == rightChildResult) { | ||
result = null; // undefined OR false | ||
} | ||
else if (null == rightChildResult) { | ||
result = null; // undefined OR undefined | ||
} | ||
} | ||
else { | ||
if (true == rightChildResult) { | ||
result = null; // undefined AND true | ||
} | ||
else if (false == rightChildResult) { | ||
result = false; // undefined AND false | ||
} | ||
else if (null == rightChildResult) { | ||
result = null; // undefined AND undefined | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// returning result | ||
return result; | ||
}; | ||
// check targeting condition | ||
this.checkTargetingCondition = function (visitorCode, targetingCondition) { | ||
var result = null; | ||
// obtaining targeting | ||
if (targetingCondition != null) { | ||
result = targetingCondition.check(_this.getTargetingData(visitorCode)); | ||
// correcting targeting result in the case an exclusion rule is asked for | ||
if (true != targetingCondition.include) { | ||
if (null == result) { | ||
result = true; | ||
} | ||
else { | ||
result = !result; | ||
} | ||
} | ||
} | ||
else { | ||
result = true; | ||
} | ||
// returning result | ||
return result; | ||
}; | ||
this.obtainVariationAssociatedData = function (variationId) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
for (var vid in (_a = _this.configurations) === null || _a === void 0 ? void 0 : _a.experiments) { | ||
var experiment = (_b = _this.configurations) === null || _b === void 0 ? void 0 : _b.experiments[vid]; | ||
if (experiment === null || experiment === void 0 ? void 0 : experiment.variationConfigurations[variationId]) { | ||
return experiment === null || experiment === void 0 ? void 0 : experiment.variationConfigurations[variationId].customJson; | ||
return (_c = experiment === null || experiment === void 0 ? void 0 : experiment.variationConfigurations[variationId].customJson) !== null && _c !== void 0 ? _c : {}; | ||
} | ||
@@ -569,10 +490,10 @@ } | ||
this.obtainFeatureVariable = function (featureIdOrName, variable) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
_this.checkFeatureKeyOrId(featureIdOrName); | ||
for (var ffid in (_a = _this.configurations) === null || _a === void 0 ? void 0 : _a.featureFlags) { | ||
var ff = (_b = _this.configurations) === null || _b === void 0 ? void 0 : _b.featureFlags[ffid]; | ||
if (ffid == featureIdOrName || (ff === null || ff === void 0 ? void 0 : ff.identificationKey) == featureIdOrName) { | ||
if (ffid == featureIdOrName || (ff === null || ff === void 0 ? void 0 : ff.identificationKey) === featureIdOrName) { | ||
for (var vid in ff === null || ff === void 0 ? void 0 : ff.variationConfigurations) { | ||
if (vid != "0") { | ||
return _this._parseJsonValue((_c = ff === null || ff === void 0 ? void 0 : ff.variationConfigurations[vid]) === null || _c === void 0 ? void 0 : _c.customJson[variable]); | ||
if (vid !== "0") { | ||
return _this._parseJsonValue((_d = (_c = ff === null || ff === void 0 ? void 0 : ff.variationConfigurations[vid]) === null || _c === void 0 ? void 0 : _c.customJson) === null || _d === void 0 ? void 0 : _d[variable]); | ||
} | ||
@@ -582,3 +503,3 @@ } | ||
} | ||
throw new featureConfigurationNotFound_1.default("KameleoonException.FeatureConfigurationNotFound"); | ||
throw new featureConfigurationNotFound_1.default("KameleoonExceptinpmon.FeatureConfigurationNotFound"); | ||
}; | ||
@@ -612,3 +533,3 @@ this.retrieveDataFromRemoteSource = function (key) { return __awaiter(_this, void 0, void 0, function () { | ||
}; | ||
this.save = function () { | ||
this.saveConfiguration = function () { | ||
var _a, _b; | ||
@@ -622,2 +543,3 @@ if (_this.configurations) { | ||
featureFlags: (_b = _this.configurations.configuration) === null || _b === void 0 ? void 0 : _b.featureFlags, | ||
configuration: _this.configurations.settings | ||
} | ||
@@ -641,2 +563,5 @@ }; | ||
}; | ||
this.onUpdateConfiguration = function (handler) { | ||
_this.handlerUpdateConfiguration = handler; | ||
}; | ||
this.siteCode = siteCode; | ||
@@ -654,5 +579,5 @@ if (configuration) { | ||
} | ||
this.targetingDataNumberEntriesAuthorized = this.visitorDataMaximumSize * 1000000 / KameleoonClient.TARGETING_DATA_MAXIMUM_SIZE_BYTES; | ||
this.updateConfiguration(); | ||
setInterval(this.emptyTargetingData, KameleoonClient.DEFAULT_MILLISECONDS_BETWEEN_TARGETING_DATA_UPDATE); | ||
this.targetingDataNumberEntriesAuthorized = this.visitorDataMaximumSize * 1000000 / constants_1.TARGETING_DATA_MAXIMUM_SIZE_BYTES; | ||
this.updateCampaignConfiguration(); | ||
setInterval(this.emptyTargetingData, constants_1.DEFAULT_MILLISECONDS_BETWEEN_TARGETING_DATA_UPDATE); | ||
} | ||
@@ -677,7 +602,20 @@ KameleoonClient.prototype.checkSiteEnabled = function (experimentOrFeatureFlag) { | ||
}; | ||
KameleoonClient.DEFAULT_MILLISECONDS_BETWEEN_TARGETING_DATA_UPDATE = 1800000; | ||
KameleoonClient.MINUTES_SESSION_DURATION = 30 * 60 * 1000; | ||
KameleoonClient.TARGETING_DATA_MAXIMUM_SIZE_BYTES = 500; | ||
KameleoonClient.API_SSX_URL = "https://api-ssx.kameleoon.com/"; | ||
KameleoonClient.API_DATA_URL = "https://api-data.kameleoon.com/"; | ||
KameleoonClient.prototype.manageConfiguraitonUpdate = function (subsciptionRequired) { | ||
var _this = this; | ||
if (subsciptionRequired && !this.realTimeConfigurationService) { | ||
this.realTimeConfigurationService = new realTimeConfigurationService_1.RealTimeConfigurationService(this.getEventsRequestURL(this.siteCode), function (event) { | ||
_this.updateCampaignConfiguration(event.ts); | ||
}); | ||
} | ||
else if (!subsciptionRequired) { | ||
if (this.realTimeConfigurationService) { | ||
this.realTimeConfigurationService.disconnect(); | ||
this.realTimeConfigurationService = null; | ||
} | ||
setTimeout(this.updateCampaignConfiguration, this.minutesBetweenConfigurationUpdate * constants_1.Milliseconds.Minute); | ||
} | ||
}; | ||
KameleoonClient.prototype.fireUpdateConfigurationHandler = function (fire) { | ||
fire && this.handlerUpdateConfiguration && this.handlerUpdateConfiguration(); | ||
}; | ||
KameleoonClient.VISITOR_CODE_MAX_LENGTH = 255; | ||
@@ -684,0 +622,0 @@ return KameleoonClient; |
declare class KameleoonUtils { | ||
doRequest: (url: string, method: HttpMethod, data?: any, callback?: any) => void; | ||
doRequest: (url: string, method: HttpMethod, data?: any, callback?: any, addKameleoonClientHeader?: boolean) => void; | ||
computeStringSha256: (string: string) => string; | ||
@@ -4,0 +4,0 @@ encodeUTF8: (string: string) => string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HttpMethod = void 0; | ||
var VERSION = "1.0.8"; | ||
var VERSION = "1.0.9"; | ||
var KameleoonUtils = /** @class */ (function () { | ||
function KameleoonUtils() { | ||
var _this = this; | ||
this.doRequest = function (url, method, data, callback) { | ||
this.doRequest = function (url, method, data, callback, addKameleoonClientHeader) { | ||
if (addKameleoonClientHeader === void 0) { addKameleoonClientHeader = true; } | ||
var xhr = new XMLHttpRequest(); | ||
@@ -16,3 +17,3 @@ xhr.onreadystatechange = function () { | ||
xhr.open(method, url, true); | ||
xhr.setRequestHeader("Kameleoon-Client", "sdk/js/" + VERSION); | ||
addKameleoonClientHeader && xhr.setRequestHeader("Kameleoon-Client", "sdk/js/" + VERSION); | ||
xhr.send(data ? data : null); | ||
@@ -19,0 +20,0 @@ }; |
@@ -1,2 +0,1 @@ | ||
declare const obtainNonce: () => string; | ||
export default obtainNonce; | ||
export declare function obtainNonce(): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.obtainNonce = void 0; | ||
var HEXADECIMAL_ALPHABET = "0123456789ABCDEF"; | ||
var NONCE_BYTE_LENGTH = 8; | ||
var obtainNonce = function () { | ||
function obtainNonce() { | ||
var alphabetLength = HEXADECIMAL_ALPHABET.length; | ||
@@ -13,3 +14,3 @@ var result = ""; | ||
return result; | ||
}; | ||
exports.default = obtainNonce; | ||
} | ||
exports.obtainNonce = obtainNonce; |
import TargetingCondition from "../targetingCondition"; | ||
import TargetingData from '../targetingData'; | ||
declare class CustomDatum extends TargetingCondition { | ||
import { TargetingConditionType } from "./types"; | ||
export declare class CustomDatum extends TargetingCondition { | ||
index: number; | ||
@@ -8,6 +8,6 @@ operator: string; | ||
include: boolean; | ||
type: string; | ||
conditionType: string; | ||
constructor(index: number, value: string, isInclude: boolean, matchType: string); | ||
check: (data: TargetingData[]) => boolean; | ||
check: (data: TargetingConditionType) => boolean; | ||
} | ||
export default CustomDatum; |
@@ -21,3 +21,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CustomDatum = void 0; | ||
var targetingCondition_1 = __importDefault(require("../targetingCondition")); | ||
var data_1 = require("../../data"); | ||
var constants_1 = require("../../constants"); | ||
var CustomDatum = /** @class */ (function (_super) { | ||
@@ -28,6 +31,6 @@ __extends(CustomDatum, _super); | ||
_this.check = function (data) { | ||
var targetingData = data.targetingData; | ||
var targeting = true; | ||
var customData = data.filter(function (d) { | ||
var data = d.data; | ||
return data.type == "CustomData" && data.id == _this.index; | ||
var customData = targetingData.filter(function (item) { | ||
return item.data instanceof data_1.CustomData && item.data.id == _this.index; | ||
}).map(function (d) { | ||
@@ -96,2 +99,17 @@ return d.data; | ||
break; | ||
case "AMONG_VALUES": { | ||
var regexp = new RegExp('"([^"]*)"', 'g'); | ||
var match = void 0; | ||
/* this.value has a format "["id1", "id2", "id3", "id3"]" | ||
need to find all matches (id1, id2, id3, id4 for current sample) | ||
in a string `this.value`and to compare them all | ||
with `customDatum.value` for a match */ | ||
while ((match = regexp.exec(_this.value)) !== null) { | ||
if (match[1] === customDatum.value) { | ||
targeting = true; | ||
break; | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
@@ -102,3 +120,3 @@ } | ||
_this.include = isInclude; | ||
_this.type = "customDatum"; | ||
_this.conditionType = constants_1.ConditionTypes.CUSTOM_DATUM; | ||
_this.index = index; | ||
@@ -111,2 +129,3 @@ _this.value = value; | ||
}(targetingCondition_1.default)); | ||
exports.CustomDatum = CustomDatum; | ||
exports.default = CustomDatum; |
@@ -1,7 +0,7 @@ | ||
import TargetingData from './targetingData'; | ||
import { TargetingConditionType } from "./conditions/types"; | ||
declare abstract class TargetingCondition { | ||
abstract type: string; | ||
abstract conditionType: string; | ||
abstract include: boolean; | ||
abstract check: (data: TargetingData[]) => boolean; | ||
abstract check: (data: TargetingConditionType) => boolean; | ||
} | ||
export default TargetingCondition; |
import CustomDatum from "./conditions/customDatum"; | ||
declare class TargetingConditionsFactory { | ||
getCondition(targetingConditionType: string, conditionData: any): CustomDatum | null; | ||
import { ExclusiveExperiment } from "./conditions/exclusiveExperiment"; | ||
import { TargetExperiment } from "./conditions/targetExperiment"; | ||
export declare class TargetingConditionsFactory { | ||
getCondition(targetingConditionType: string, conditionData: any): CustomDatum | ExclusiveExperiment | TargetExperiment | null; | ||
} | ||
export default TargetingConditionsFactory; |
@@ -6,3 +6,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TargetingConditionsFactory = void 0; | ||
var constants_1 = require("../constants"); | ||
var customDatum_1 = __importDefault(require("./conditions/customDatum")); | ||
var exclusiveExperiment_1 = require("./conditions/exclusiveExperiment"); | ||
var targetExperiment_1 = require("./conditions/targetExperiment"); | ||
var TargetingConditionsFactory = /** @class */ (function () { | ||
@@ -12,9 +16,16 @@ function TargetingConditionsFactory() { | ||
TargetingConditionsFactory.prototype.getCondition = function (targetingConditionType, conditionData) { | ||
if (targetingConditionType == "CUSTOM_DATUM") { | ||
return new customDatum_1.default(parseInt(conditionData.customDataIndex), conditionData.value, conditionData.isInclude, conditionData.valueMatchType); | ||
switch (targetingConditionType) { | ||
case constants_1.ConditionTypes.CUSTOM_DATUM: | ||
return new customDatum_1.default(parseInt(conditionData.customDataIndex), conditionData.value, conditionData.isInclude, conditionData.valueMatchType); | ||
case constants_1.ConditionTypes.EXCLUSIVE_EXPERIMENT: | ||
return new exclusiveExperiment_1.ExclusiveExperiment(); | ||
case constants_1.ConditionTypes.TARGET_EXPERIMENT: | ||
return new targetExperiment_1.TargetExperiment(conditionData.isInclude, conditionData.experiment, conditionData.variation, conditionData.variationMatchType); | ||
default: | ||
return null; | ||
} | ||
return null; | ||
}; | ||
return TargetingConditionsFactory; | ||
}()); | ||
exports.TargetingConditionsFactory = TargetingConditionsFactory; | ||
exports.default = TargetingConditionsFactory; |
{ | ||
"name": "kameleoon-client-javascript", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "JavaScript SDK client", | ||
@@ -5,0 +5,0 @@ "main": "dist/kameleoonClient.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118972
70
2473