expf-sigma-node.js 3.3.5 → 3.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/sigma.js +21 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expf-sigma-node.js",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.6",
|
|
4
4
|
"description": "expf-sigma-node.js lets you manage features flags and remote config across web, server side applications. Deliver true Continuous Integration. Get builds out faster. Control who has access to new features.",
|
|
5
5
|
"main": "public/sigma.js",
|
|
6
6
|
"keywords": [
|
package/public/sigma.js
CHANGED
|
@@ -1017,13 +1017,7 @@ var sigmaGeoCache = new import_node_cache2.default({
|
|
|
1017
1017
|
checkperiod: cacheCheckPeriod
|
|
1018
1018
|
});
|
|
1019
1019
|
var SigmaGeoCache = class {
|
|
1020
|
-
|
|
1021
|
-
minGeoCacheTTL = 1 * 60;
|
|
1022
|
-
constructor(postfix, geoCacheTTL) {
|
|
1023
|
-
this.geoCacheTTL = geoCacheTTL || defaultGeoCacheTTL;
|
|
1024
|
-
if (geoCacheTTL > this.maxGeoCacheTTL || geoCacheTTL < this.minGeoCacheTTL) {
|
|
1025
|
-
this.geoCacheTTL = defaultGeoCacheTTL;
|
|
1026
|
-
}
|
|
1020
|
+
constructor(postfix) {
|
|
1027
1021
|
this.postfix = "";
|
|
1028
1022
|
if (postfix)
|
|
1029
1023
|
this.postfix = "__" + postfix;
|
|
@@ -1037,7 +1031,7 @@ var SigmaGeoCache = class {
|
|
|
1037
1031
|
}
|
|
1038
1032
|
set(key, value) {
|
|
1039
1033
|
try {
|
|
1040
|
-
return sigmaGeoCache.set(key + this.postfix, value
|
|
1034
|
+
return sigmaGeoCache.set(key + this.postfix, value);
|
|
1041
1035
|
} catch (e) {
|
|
1042
1036
|
console.log(e);
|
|
1043
1037
|
}
|
|
@@ -1268,7 +1262,7 @@ function generateFilteredList(array, name) {
|
|
|
1268
1262
|
}
|
|
1269
1263
|
|
|
1270
1264
|
// package.json
|
|
1271
|
-
var version = "3.3.
|
|
1265
|
+
var version = "3.3.6";
|
|
1272
1266
|
|
|
1273
1267
|
// src/helpers/sdkVersion.js
|
|
1274
1268
|
var sdkVersion = version;
|
|
@@ -1323,7 +1317,6 @@ var Sigma = class {
|
|
|
1323
1317
|
this.api = options.api || defaultApi;
|
|
1324
1318
|
this.retries = options.retries || 2;
|
|
1325
1319
|
this.postfix = options.postfix || "";
|
|
1326
|
-
this.geoCacheTTL = options.geoCacheTTL || defaultGeoCacheTTL;
|
|
1327
1320
|
this.sigmaUserData = new SigmaUserData();
|
|
1328
1321
|
this.cache = new SigmaCache(this.postfix);
|
|
1329
1322
|
this.sigmaUserData.init({
|
|
@@ -1346,7 +1339,7 @@ var Sigma = class {
|
|
|
1346
1339
|
});
|
|
1347
1340
|
this.setSplitIdsToCache(this.userData);
|
|
1348
1341
|
this.makePrivateIdInCache();
|
|
1349
|
-
this.geoCache = new SigmaGeoCache(`${this.cache.get(sigmaPrivateId)}__${this.token}
|
|
1342
|
+
this.geoCache = new SigmaGeoCache(`${this.cache.get(sigmaPrivateId)}__${this.token}`);
|
|
1350
1343
|
}
|
|
1351
1344
|
setSplitIdsToCache(userData) {
|
|
1352
1345
|
for (let [key, value] of Object.entries(userData)) {
|
|
@@ -1463,14 +1456,20 @@ var Sigma = class {
|
|
|
1463
1456
|
console.error(errorMessages.APIRequestErrorConfig);
|
|
1464
1457
|
}
|
|
1465
1458
|
}
|
|
1459
|
+
this.recordLastUpdateInCache();
|
|
1460
|
+
}
|
|
1461
|
+
async saveToGeoCache() {
|
|
1466
1462
|
try {
|
|
1467
1463
|
await this.getUserGeoData();
|
|
1468
|
-
|
|
1464
|
+
this.geoCache.get(sigmaGeoData) ? this.sigmaUserData.setGeo(this.geoCache.parse(sigmaGeoData)) : this.sigmaUserData.setGeo("{}");
|
|
1465
|
+
} catch (error) {
|
|
1469
1466
|
if (!this.geoCache.get(sigmaGeoData)) {
|
|
1470
1467
|
this.geoCache.set(sigmaGeoData, JSON.stringify({ location: "none" }));
|
|
1471
1468
|
}
|
|
1469
|
+
errorMessages.APIRequestErrorGeoData.token = this.token;
|
|
1470
|
+
errorMessages.APIRequestErrorGeoData.userData = JSON.stringify(this.userData);
|
|
1471
|
+
console.error(error, errorMessages.APIRequestErrorGeoData);
|
|
1472
1472
|
}
|
|
1473
|
-
this.recordLastUpdateInCache();
|
|
1474
1473
|
}
|
|
1475
1474
|
hasExpireCache() {
|
|
1476
1475
|
const lastUpdate = Number(this.cache.get(sigmaDataFileLastUpdate));
|
|
@@ -1486,6 +1485,11 @@ var Sigma = class {
|
|
|
1486
1485
|
}
|
|
1487
1486
|
return true;
|
|
1488
1487
|
}
|
|
1488
|
+
updateGeoCache() {
|
|
1489
|
+
if (!this.geoCache.get(sigmaGeoData)) {
|
|
1490
|
+
this.saveToGeoCache();
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1489
1493
|
async getFlags() {
|
|
1490
1494
|
await this.updateCache();
|
|
1491
1495
|
const flags = this.cache.parse(sigmaDataFile);
|
|
@@ -1497,10 +1501,10 @@ var Sigma = class {
|
|
|
1497
1501
|
if (!flagName)
|
|
1498
1502
|
return null;
|
|
1499
1503
|
await this.updateCache();
|
|
1504
|
+
await this.updateGeoCache();
|
|
1500
1505
|
const cacheKey = this.cache.parse(sigmaDataFile);
|
|
1501
1506
|
if (!cacheKey.feature_flags)
|
|
1502
1507
|
return;
|
|
1503
|
-
this.sigmaUserData.setGeo(this.geoCache.parse(sigmaGeoData));
|
|
1504
1508
|
let flag = null;
|
|
1505
1509
|
const expName = this.getExperimentByFeatureFlag(cacheKey, flagName);
|
|
1506
1510
|
if (expName) {
|
|
@@ -1521,8 +1525,8 @@ var Sigma = class {
|
|
|
1521
1525
|
async getUserFeatureFlagsDetails() {
|
|
1522
1526
|
const featureFlags = [];
|
|
1523
1527
|
await this.updateCache();
|
|
1528
|
+
await this.updateGeoCache();
|
|
1524
1529
|
const sigmaDataLs = await this.cache.parse(sigmaDataFile);
|
|
1525
|
-
this.sigmaUserData.setGeo(this.geoCache.parse(sigmaGeoData));
|
|
1526
1530
|
if (sigmaDataLs.feature_flags.length > 0) {
|
|
1527
1531
|
for (const flag in sigmaDataLs.feature_flags) {
|
|
1528
1532
|
const ffName = sigmaDataLs.feature_flags[flag].name;
|
|
@@ -1689,6 +1693,7 @@ var Sigma = class {
|
|
|
1689
1693
|
if (!experimentName)
|
|
1690
1694
|
return null;
|
|
1691
1695
|
await this.updateCache();
|
|
1696
|
+
await this.updateGeoCache();
|
|
1692
1697
|
const sigmaDataLs = await this.cache.parse(sigmaDataFile);
|
|
1693
1698
|
this.sigmaUserData.setGeo(this.geoCache.parse(sigmaGeoData));
|
|
1694
1699
|
if (!sigmaDataLs.experiments)
|
|
@@ -1786,6 +1791,7 @@ var Sigma = class {
|
|
|
1786
1791
|
}
|
|
1787
1792
|
async getAllUserExperiments() {
|
|
1788
1793
|
await this.updateCache();
|
|
1794
|
+
await this.updateGeoCache();
|
|
1789
1795
|
const sigmaDataLs = this.cache.parse(sigmaDataFile);
|
|
1790
1796
|
if (!sigmaDataLs.experiments.length)
|
|
1791
1797
|
return null;
|