Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kameleoon-client-javascript

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kameleoon-client-javascript - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

CHANGELOG.md

9

dist/configurations/featureFlag.d.ts

@@ -5,2 +5,6 @@ import TargetingSegment from "../targeting/targetingSegment";

declare class FeatureFlag {
static readonly STATUS_ACTIVE = "ACTIVE";
static readonly FEATURE_STATUS_DEACTIVATED = "DEACTIVATED";
status: string;
featureStatus: string;
variationConfigurations: {

@@ -12,4 +16,9 @@ [id: string]: Variation;

identificationKey: string;
schedules: {
dateStart: number;
dateEnd: number;
}[];
constructor(featureFlag: AutomationFeatureFlagInterface);
isScheduleActive: () => boolean;
}
export default FeatureFlag;

@@ -12,4 +12,35 @@ "use strict";

var _this = this;
this.isScheduleActive = function () {
// if no schedules then need to fetch current status
var currentStatus = _this.status == FeatureFlag.STATUS_ACTIVE;
if (_this.featureStatus == FeatureFlag.FEATURE_STATUS_DEACTIVATED || _this.schedules.length == 0) {
return currentStatus;
}
var currentTime = new Date().getTime();
var times = [];
_this.schedules.forEach(function (schedule) {
times.push([schedule.dateStart, true]);
times.push([schedule.dateEnd, false]);
});
times.sort(function (a, b) { return a[0] - b[0]; });
times.forEach(function (time) {
if (time[0] < currentTime) {
currentStatus = time[1];
}
});
return currentStatus;
};
this.variationConfigurations = {};
this.identificationKey = featureFlag.identificationKey;
this.status = featureFlag.status;
this.featureStatus = featureFlag.featureStatus;
this.schedules = [];
if (featureFlag.schedules) {
featureFlag.schedules.forEach(function (schedule) {
_this.schedules.push({
dateStart: schedule.dateStart ? Date.parse(schedule.dateStart) : -Infinity,
dateEnd: schedule.dateEnd ? Date.parse(schedule.dateEnd) : Infinity,
});
});
}
var deviations = featureFlag.deviations || null;

@@ -60,4 +91,6 @@ if (deviations) {

}
FeatureFlag.STATUS_ACTIVE = "ACTIVE";
FeatureFlag.FEATURE_STATUS_DEACTIVATED = "DEACTIVATED";
return FeatureFlag;
}());
exports.default = FeatureFlag;

@@ -18,2 +18,3 @@ /// <reference types="node" />

deviations: AutomationDeviationInterface[];
featureStatus: string;
id: string;

@@ -23,2 +24,6 @@ identificationKey: string;

respoolTime?: AutomationRespoolTimeInterface[];
schedules: {
dateStart?: string;
dateEnd?: string;
}[] | null;
segment?: AutomationSegmentInterface;

@@ -25,0 +30,0 @@ siteCode: string;

40

dist/kameleoonClient.js

@@ -79,3 +79,3 @@ "use strict";

if (needUpdate) {
kameleoonUtils_1.default.doRequest("https://customers.kameleoon.com/mobile/?siteCode=" + _this.siteCode, "GET", null, function (response) {
kameleoonUtils_1.default.doRequest("https://customers.kameleoon.com/mobile/configuration?siteCode=" + _this.siteCode, "GET", null, function (response) {
try {

@@ -201,21 +201,25 @@ _this.configurations = new configuration_1.default(_this.siteCode, JSON.parse(response));

if (featureFlag && featureId) {
var hashDouble = _this.obtainHashDouble(featureId, visitorCode, featureFlag);
var total = 0.0;
var variationId = 0;
var noneVariation = true;
for (var key in featureFlag.variationConfigurations) {
var variationConfiguration = featureFlag.variationConfigurations[key];
total += variationConfiguration.deviation;
if (total >= hashDouble) {
noneVariation = false;
variationId = parseInt(key);
break;
var result = false;
if (featureFlag.isScheduleActive()) {
var hashDouble = _this.obtainHashDouble(featureId, visitorCode, featureFlag);
var total = 0.0;
var variationId = 0;
var noneVariation = true;
for (var key in featureFlag.variationConfigurations) {
var variationConfiguration = featureFlag.variationConfigurations[key];
total += variationConfiguration.deviation;
if (total >= hashDouble) {
noneVariation = false;
variationId = parseInt(key);
break;
}
}
var body = "";
_this.getUnsentData(visitorCode).forEach(function (element) {
body += element.obtainFullPostTextLine() + "\n";
});
kameleoonUtils_1.default.doRequest(KameleoonClient.API_SSX_URL + _this.getExperimentRegisterURL(visitorCode, featureId, variationId, noneVariation), "POST", body);
result = variationId != 0;
}
var body = "";
_this.getUnsentData(visitorCode).forEach(function (element) {
body += element.obtainFullPostTextLine() + "\n";
});
kameleoonUtils_1.default.doRequest(KameleoonClient.API_SSX_URL + _this.getExperimentRegisterURL(visitorCode, featureId, variationId, noneVariation), "POST", body);
return variationId != 0;
return result;
}

@@ -222,0 +226,0 @@ else {

{
"name": "kameleoon-client-javascript",
"version": "1.0.3",
"version": "1.0.4",
"description": "JavaScript SDK client",

@@ -5,0 +5,0 @@ "main": "dist/kameleoonClient.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc