kameleoon-client-javascript
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -20,6 +20,6 @@ import { DataInterface } from './interfaces/interfaces'; | ||
title: string; | ||
referrer: number; | ||
referrer?: number; | ||
nonce: string; | ||
type: string; | ||
constructor(url: string, title: string, referrer: number); | ||
constructor(url: string, title: string, referrer?: number); | ||
obtainFullPostTextLine: () => string; | ||
@@ -26,0 +26,0 @@ } |
@@ -20,2 +20,3 @@ import Configuration from './configurations/configuration'; | ||
static readonly API_SSX_URL: string; | ||
static readonly VISITOR_CODE_MAX_LENGTH = 255; | ||
configurations?: Configuration; | ||
@@ -38,5 +39,5 @@ ready: boolean; | ||
clearCallbacks: (success: boolean, errorCallback?: (() => void) | undefined) => void; | ||
trackConversion: (visitorCode: string, goalId: number, revenue: number) => void; | ||
trackConversion: (visitorCode: string, goalId: number, revenue?: number | undefined) => void; | ||
flush: (visitorCode: string) => void; | ||
triggerExperiment: (visitorCode: string, experimentId: number, callback: any) => number; | ||
triggerExperiment: (visitorCode: string, experimentId: number, timeout?: any) => number; | ||
activateFeature: (visitorCode: string, featureIdOrName: number | string) => boolean; | ||
@@ -61,2 +62,3 @@ generateRandomString: () => string; | ||
save: () => void; | ||
private validateVisitorCode; | ||
} | ||
@@ -63,0 +65,0 @@ declare const KameleoonException: { |
@@ -19,2 +19,3 @@ "use strict"; | ||
var credentialsNotFound_1 = __importDefault(require("./exceptions/credentialsNotFound")); | ||
var visitorCodeNotValid_1 = require("./exceptions/visitorCodeNotValid"); | ||
var KameleoonClient = /** @class */ (function () { | ||
@@ -129,2 +130,3 @@ function KameleoonClient(siteCode, configuration) { | ||
this.trackConversion = function (visitorCode, goalId, revenue) { | ||
_this.validateVisitorCode(visitorCode); | ||
_this.addData(visitorCode, new data_1.default.Conversion(goalId, revenue, false)); | ||
@@ -149,4 +151,5 @@ _this.flush(visitorCode); | ||
}; | ||
this.triggerExperiment = function (visitorCode, experimentId, callback) { | ||
this.triggerExperiment = function (visitorCode, experimentId, timeout) { | ||
var _a; | ||
_this.validateVisitorCode(visitorCode); | ||
if (_this.checkTargeting(visitorCode, experimentId, false)) { | ||
@@ -188,2 +191,3 @@ var xpConf = (_a = _this.configurations) === null || _a === void 0 ? void 0 : _a.experiments[experimentId]; | ||
var _a, _b; | ||
_this.validateVisitorCode(visitorCode); | ||
var featureFlag = null; | ||
@@ -319,2 +323,3 @@ var featureId = -1; | ||
} | ||
_this.validateVisitorCode(visitorCode); | ||
var listData = _this.getUnsentData(visitorCode); | ||
@@ -525,2 +530,10 @@ var targetingDataList = _this.getTargetingData(visitorCode); | ||
}; | ||
this.validateVisitorCode = function (visitorCode) { | ||
if (visitorCode == null || visitorCode.length == 0) { | ||
throw new visitorCodeNotValid_1.VisitorCodeNotValid("Visitor code is empty"); | ||
} | ||
else if (visitorCode.length > KameleoonClient.VISITOR_CODE_MAX_LENGTH) { | ||
throw new visitorCodeNotValid_1.VisitorCodeNotValid("Visitor code max length is " + KameleoonClient.VISITOR_CODE_MAX_LENGTH + " characters"); | ||
} | ||
}; | ||
this.siteCode = siteCode; | ||
@@ -543,2 +556,3 @@ if (configuration) { | ||
KameleoonClient.API_SSX_URL = "https://api-ssx.kameleoon.com/"; | ||
KameleoonClient.VISITOR_CODE_MAX_LENGTH = 255; | ||
return KameleoonClient; | ||
@@ -545,0 +559,0 @@ }()); |
@@ -14,2 +14,3 @@ "use strict"; | ||
xhr.open(method, url, true); | ||
xhr.setRequestHeader("Kameleoon-Client", "sdk/js/1.0.3"); | ||
xhr.send(data ? data : null); | ||
@@ -16,0 +17,0 @@ }; |
{ | ||
"name": "kameleoon-client-javascript", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "JavaScript SDK client", | ||
@@ -5,0 +5,0 @@ "main": "dist/kameleoonClient.js", |
77618
48
1724