expf-sigma-node.js 3.4.0 → 3.4.1
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 +14 -49
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expf-sigma-node.js",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.1",
|
|
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
|
@@ -918,13 +918,9 @@ var sigmaHashes_default = Hashes;
|
|
|
918
918
|
|
|
919
919
|
// src/helpers/constants.js
|
|
920
920
|
var defaultApi = "https://api.expf.ru/api/v1";
|
|
921
|
-
var sigmaUserId = "sigmaUserId";
|
|
922
|
-
var sigmaProfileId = "sigmaProfileId";
|
|
923
|
-
var sigmaDeviceId = "sigmaDeviceId";
|
|
924
921
|
var sigmaPrivateId = "sigmaPrivateId";
|
|
925
922
|
var sigmaHash = "sigmaHash";
|
|
926
923
|
var sigmaDataFileLastUpdate = "sigmaDataFileLastUpdate";
|
|
927
|
-
var sigmaExpiration = "sigmaExpiration";
|
|
928
924
|
var sigmaDataFile = "sigmaDataFile";
|
|
929
925
|
var sigmaExperiments = "sigmaExperiments";
|
|
930
926
|
var sigmaHoldouts = "sigmaHoldouts";
|
|
@@ -933,7 +929,6 @@ var max_decimal_64 = 18446744073709552e3;
|
|
|
933
929
|
var zeta = 8540717056e4;
|
|
934
930
|
var SHA256 = new sigmaHashes_default.SHA256();
|
|
935
931
|
var MD5 = new sigmaHashes_default.MD5();
|
|
936
|
-
var expirationDate = 24 * 60 * 60 * 1e3;
|
|
937
932
|
var secondsIn24Hours = 24 * 60 * 60;
|
|
938
933
|
var defaultGeoCacheTTL = 5 * 60;
|
|
939
934
|
var cacheStandardTimeToLive = 3600;
|
|
@@ -1271,7 +1266,7 @@ function generateFilteredList(array, name) {
|
|
|
1271
1266
|
}
|
|
1272
1267
|
|
|
1273
1268
|
// package.json
|
|
1274
|
-
var version = "3.4.
|
|
1269
|
+
var version = "3.4.1";
|
|
1275
1270
|
|
|
1276
1271
|
// src/helpers/sdkVersion.js
|
|
1277
1272
|
var sdkVersion = version;
|
|
@@ -1346,28 +1341,9 @@ var Sigma = class {
|
|
|
1346
1341
|
pathname: this.userData.pathname || null,
|
|
1347
1342
|
ua: this.userData.ua || void 0
|
|
1348
1343
|
});
|
|
1349
|
-
this.setSplitIdsToCache(this.userData);
|
|
1350
1344
|
this.makePrivateIdInCache();
|
|
1351
1345
|
this.geoCache = new SigmaGeoCache(`${this.cache.get(sigmaPrivateId)}__${this.token}`);
|
|
1352
1346
|
}
|
|
1353
|
-
setSplitIdsToCache(userData) {
|
|
1354
|
-
for (let [key, value] of Object.entries(userData)) {
|
|
1355
|
-
if (!value || !String(value).trim().length)
|
|
1356
|
-
continue;
|
|
1357
|
-
switch (key) {
|
|
1358
|
-
case "userId":
|
|
1359
|
-
this.cache.set(sigmaUserId, String(value).trim());
|
|
1360
|
-
this.cache.set(sigmaExpiration, new Date().getTime() + expirationDate);
|
|
1361
|
-
break;
|
|
1362
|
-
case "profileId":
|
|
1363
|
-
this.cache.set(sigmaProfileId, String(value).trim());
|
|
1364
|
-
break;
|
|
1365
|
-
case "deviceId":
|
|
1366
|
-
this.cache.set(sigmaDeviceId, String(value).trim());
|
|
1367
|
-
break;
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
1347
|
makePrivateIdInCache() {
|
|
1372
1348
|
if (!this.cache.get(sigmaPrivateId)) {
|
|
1373
1349
|
this.cache.set(sigmaPrivateId, generateRandomId());
|
|
@@ -1635,19 +1611,15 @@ var Sigma = class {
|
|
|
1635
1611
|
}
|
|
1636
1612
|
switchSplitById(splitBy) {
|
|
1637
1613
|
let id = null;
|
|
1638
|
-
const cacheSigmaExpiration = this.cache.get(sigmaExpiration);
|
|
1639
1614
|
switch (splitBy) {
|
|
1640
1615
|
case "userId":
|
|
1641
|
-
id = this.
|
|
1642
|
-
if (typeof cacheSigmaExpiration !== "undefined" && new Date().getTime() >= Number(cacheSigmaExpiration)) {
|
|
1643
|
-
id = null;
|
|
1644
|
-
}
|
|
1616
|
+
id = this.userData.userId ? String(this.userData.userId).trim() : null;
|
|
1645
1617
|
break;
|
|
1646
1618
|
case "profileId":
|
|
1647
|
-
id = this.
|
|
1619
|
+
id = this.userData.profileId ? String(this.userData.profileId).trim() : null;
|
|
1648
1620
|
break;
|
|
1649
1621
|
case "deviceId":
|
|
1650
|
-
id = this.
|
|
1622
|
+
id = this.userData.deviceId ? String(this.userData.deviceId).trim() : null;
|
|
1651
1623
|
break;
|
|
1652
1624
|
}
|
|
1653
1625
|
return id;
|
|
@@ -2026,10 +1998,6 @@ var Sigma = class {
|
|
|
2026
1998
|
const data = await this.cache.get(sigmaHash);
|
|
2027
1999
|
return data;
|
|
2028
2000
|
}
|
|
2029
|
-
async getCacheUserId() {
|
|
2030
|
-
const data = await this.cache.get(sigmaUserId);
|
|
2031
|
-
return data;
|
|
2032
|
-
}
|
|
2033
2001
|
checkConditionsStatement(ruleStatement, items) {
|
|
2034
2002
|
let isSuccessRule = false;
|
|
2035
2003
|
if (ruleStatement == "OR") {
|
|
@@ -2048,14 +2016,11 @@ var Sigma = class {
|
|
|
2048
2016
|
}
|
|
2049
2017
|
}
|
|
2050
2018
|
clearUserProperties() {
|
|
2051
|
-
this.
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
sigmaProfileId,
|
|
2055
|
-
sigmaExpiration,
|
|
2056
|
-
sigmaExperiments
|
|
2057
|
-
]);
|
|
2019
|
+
this.userData.userId = void 0;
|
|
2020
|
+
this.userData.profileId = void 0;
|
|
2021
|
+
this.userData.deviceId = void 0;
|
|
2058
2022
|
this.sigmaUserData.removeInjectedProperties();
|
|
2023
|
+
this.clearCacheByKeys([sigmaExperiments]);
|
|
2059
2024
|
}
|
|
2060
2025
|
overwriteGeoCache(key, value) {
|
|
2061
2026
|
const geoCache = this.geoCache.parse(sigmaGeoData);
|
|
@@ -2066,17 +2031,17 @@ var Sigma = class {
|
|
|
2066
2031
|
return {
|
|
2067
2032
|
setUserId: (userId) => {
|
|
2068
2033
|
this.sigmaUserData.setUserId(userId);
|
|
2069
|
-
this.
|
|
2034
|
+
this.userData.userId = userId;
|
|
2070
2035
|
return this.editUserProperties();
|
|
2071
2036
|
},
|
|
2072
2037
|
setDeviceId: (deviceId) => {
|
|
2073
2038
|
this.sigmaUserData.setDeviceId(deviceId);
|
|
2074
|
-
this.
|
|
2039
|
+
this.userData.deviceId = deviceId;
|
|
2075
2040
|
return this.editUserProperties();
|
|
2076
2041
|
},
|
|
2077
2042
|
setProfileId: (profileId) => {
|
|
2078
2043
|
this.sigmaUserData.setProfileId(profileId);
|
|
2079
|
-
this.
|
|
2044
|
+
this.userData.profileId = profileId;
|
|
2080
2045
|
return this.editUserProperties();
|
|
2081
2046
|
},
|
|
2082
2047
|
setEmail: (email) => {
|
|
@@ -2134,17 +2099,17 @@ var Sigma = class {
|
|
|
2134
2099
|
},
|
|
2135
2100
|
removeUserId: () => {
|
|
2136
2101
|
this.sigmaUserData.removeUserId();
|
|
2137
|
-
this.
|
|
2102
|
+
this.userData.userId = void 0;
|
|
2138
2103
|
return this.editUserProperties();
|
|
2139
2104
|
},
|
|
2140
2105
|
removeDeviceId: () => {
|
|
2141
2106
|
this.sigmaUserData.removeDeviceId();
|
|
2142
|
-
this.
|
|
2107
|
+
this.userData.deviceId = void 0;
|
|
2143
2108
|
return this.editUserProperties();
|
|
2144
2109
|
},
|
|
2145
2110
|
removeProfileId: () => {
|
|
2146
2111
|
this.sigmaUserData.removeProfileId();
|
|
2147
|
-
this.
|
|
2112
|
+
this.userData.profileId = void 0;
|
|
2148
2113
|
return this.editUserProperties();
|
|
2149
2114
|
},
|
|
2150
2115
|
removeAppVersion: () => {
|