expf-sigma-node.js 1.0.0 → 1.1.0
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 +20 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expf-sigma-node.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
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
|
@@ -68,7 +68,10 @@ var SigmaUserData = class {
|
|
|
68
68
|
email,
|
|
69
69
|
appVersion,
|
|
70
70
|
custom,
|
|
71
|
-
deviceCategory
|
|
71
|
+
deviceCategory,
|
|
72
|
+
os,
|
|
73
|
+
browser,
|
|
74
|
+
geo
|
|
72
75
|
}) {
|
|
73
76
|
this.user.userId = userId;
|
|
74
77
|
this.user.ip = ip;
|
|
@@ -78,8 +81,9 @@ var SigmaUserData = class {
|
|
|
78
81
|
this.user.time = new Date().getTime() / (1e3 * 60 * 60);
|
|
79
82
|
this.user.date = Math.floor(new Date().getTime() / (1e3 * 60 * 60 * 24));
|
|
80
83
|
this.user.deviceCategory = deviceCategory;
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
this.user.os = os;
|
|
85
|
+
this.user.browser = browser;
|
|
86
|
+
this.user.geo = geo;
|
|
83
87
|
}
|
|
84
88
|
setUserId(userId) {
|
|
85
89
|
this.user.userId = userId;
|
|
@@ -877,6 +881,7 @@ var defaultApi = "https://api.expf.ru/api/v1";
|
|
|
877
881
|
var sigmaUserId = "sigmaUserId";
|
|
878
882
|
var sigmaDataFile = "sigmaDataFile";
|
|
879
883
|
var sigmaExperiments = "sigmaExperiments";
|
|
884
|
+
var sigmaGeoData = "sigmaGeoData";
|
|
880
885
|
var SHA256 = new sigmaHashes_default.SHA256();
|
|
881
886
|
var MD5 = new sigmaHashes_default.MD5();
|
|
882
887
|
var max_decimal_64 = 18446744073709552e3;
|
|
@@ -905,7 +910,10 @@ var Sigma = class {
|
|
|
905
910
|
email: this.userData.email || null,
|
|
906
911
|
appVersion: this.userData.appVersion || null,
|
|
907
912
|
custom: this.userData.custom || null,
|
|
908
|
-
deviceCategory: this.userData.deviceCategory || null
|
|
913
|
+
deviceCategory: this.userData.deviceCategory || null,
|
|
914
|
+
browser: this.userData.browser || null,
|
|
915
|
+
os: this.userData.os || null,
|
|
916
|
+
geo: this.userData.geo || null
|
|
909
917
|
});
|
|
910
918
|
this.cache.set(sigmaUserId, this.userData.userId);
|
|
911
919
|
this.setUserCookie();
|
|
@@ -969,7 +977,6 @@ var Sigma = class {
|
|
|
969
977
|
async getUserGeoData() {
|
|
970
978
|
try {
|
|
971
979
|
const data = await this.getDataFile(`${defaultApi}/geo`);
|
|
972
|
-
this.sigmaUserData.setIp(data.ip);
|
|
973
980
|
return data;
|
|
974
981
|
} catch (error) {
|
|
975
982
|
throw new Error(error);
|
|
@@ -987,13 +994,16 @@ var Sigma = class {
|
|
|
987
994
|
`);
|
|
988
995
|
}
|
|
989
996
|
try {
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
this.cache.
|
|
993
|
-
|
|
997
|
+
if (!this.userData.geo) {
|
|
998
|
+
const userGeoData = await this.getUserGeoData();
|
|
999
|
+
if (!this.cache.get(sigmaGeoData) || this.cache.get(sigmaGeoData, { location: "none" }) && userGeoData) {
|
|
1000
|
+
this.cache.set(sigmaGeoData, JSON.stringify(userGeoData));
|
|
1001
|
+
}
|
|
1002
|
+
} else {
|
|
1003
|
+
this.cache.set(sigmaGeoData, JSON.stringify(this.userData.geo));
|
|
994
1004
|
}
|
|
995
1005
|
} catch (error) {
|
|
996
|
-
this.cache.set(
|
|
1006
|
+
this.cache.set(sigmaGeoData, JSON.stringify({ location: "none" }));
|
|
997
1007
|
console.error(error);
|
|
998
1008
|
}
|
|
999
1009
|
let data;
|