expf-sigma-node.js 3.2.12 → 3.3.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 +289 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expf-sigma-node.js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.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
|
@@ -135,9 +135,6 @@ var SigmaUserData = class {
|
|
|
135
135
|
version: os.version || void 0
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
-
setUserId(userId) {
|
|
139
|
-
this.user.userId = userId;
|
|
140
|
-
}
|
|
141
138
|
setIp(ip) {
|
|
142
139
|
this.user.ip = ip;
|
|
143
140
|
}
|
|
@@ -151,11 +148,133 @@ var SigmaUserData = class {
|
|
|
151
148
|
});
|
|
152
149
|
}
|
|
153
150
|
}
|
|
151
|
+
setGeo(data) {
|
|
152
|
+
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
153
|
+
return;
|
|
154
|
+
this.user.geo = data;
|
|
155
|
+
}
|
|
154
156
|
clearFlags() {
|
|
155
157
|
this.user.featureFlags = [];
|
|
156
158
|
}
|
|
157
|
-
|
|
158
|
-
this.user.
|
|
159
|
+
removeInjectedProperties() {
|
|
160
|
+
this.user.appVersion = null;
|
|
161
|
+
this.user.userId = null;
|
|
162
|
+
this.user.profileId = null;
|
|
163
|
+
this.user.deviceId = null;
|
|
164
|
+
this.user.email = null;
|
|
165
|
+
this.user.custom = { name: null, value: null };
|
|
166
|
+
}
|
|
167
|
+
setUserId(userId) {
|
|
168
|
+
if (!userId)
|
|
169
|
+
this.user.userId = null;
|
|
170
|
+
this.user.userId = userId;
|
|
171
|
+
}
|
|
172
|
+
setDeviceId(deviceId) {
|
|
173
|
+
if (!deviceId)
|
|
174
|
+
this.user.deviceId = null;
|
|
175
|
+
this.user.deviceId = deviceId;
|
|
176
|
+
}
|
|
177
|
+
setProfileId(profileId) {
|
|
178
|
+
if (!profileId)
|
|
179
|
+
this.user.profileId = null;
|
|
180
|
+
this.user.profileId = profileId;
|
|
181
|
+
}
|
|
182
|
+
setEmail(email) {
|
|
183
|
+
if (!email)
|
|
184
|
+
this.user.email = null;
|
|
185
|
+
this.user.email = email;
|
|
186
|
+
}
|
|
187
|
+
setAppVersion(appVersion) {
|
|
188
|
+
if (!appVersion)
|
|
189
|
+
this.user.appVersion = null;
|
|
190
|
+
this.user.appVersion = appVersion;
|
|
191
|
+
}
|
|
192
|
+
setBrowserName(browserName) {
|
|
193
|
+
if (!browserName)
|
|
194
|
+
return;
|
|
195
|
+
this.user.browser.name = browserName;
|
|
196
|
+
}
|
|
197
|
+
setBrowserVersion(browserVersion) {
|
|
198
|
+
if (!browserVersion)
|
|
199
|
+
return;
|
|
200
|
+
this.user.browser.version = browserVersion;
|
|
201
|
+
}
|
|
202
|
+
setOsName(osName) {
|
|
203
|
+
if (!osName)
|
|
204
|
+
return;
|
|
205
|
+
this.user.os.name = osName;
|
|
206
|
+
}
|
|
207
|
+
setOsVersion(osVersion) {
|
|
208
|
+
if (!osVersion)
|
|
209
|
+
return;
|
|
210
|
+
this.user.os.version = osVersion;
|
|
211
|
+
}
|
|
212
|
+
setGeoCountry(country) {
|
|
213
|
+
this.user.geo.country = country;
|
|
214
|
+
}
|
|
215
|
+
setGeoCode(code) {
|
|
216
|
+
this.user.geo.code = code;
|
|
217
|
+
}
|
|
218
|
+
setGeoState(state) {
|
|
219
|
+
this.user.geo.state = state;
|
|
220
|
+
}
|
|
221
|
+
setGeoCity(city) {
|
|
222
|
+
this.user.geo.city = city;
|
|
223
|
+
}
|
|
224
|
+
setGeoIp(ip) {
|
|
225
|
+
this.user.geo.ip = ip;
|
|
226
|
+
}
|
|
227
|
+
setCustomProperty(key, value) {
|
|
228
|
+
if (typeof key !== "string")
|
|
229
|
+
return;
|
|
230
|
+
this.user.custom = { ...this.user.custom, [key]: value };
|
|
231
|
+
}
|
|
232
|
+
removeUserId() {
|
|
233
|
+
this.user.userId = null;
|
|
234
|
+
}
|
|
235
|
+
removeDeviceId() {
|
|
236
|
+
this.user.deviceId = null;
|
|
237
|
+
}
|
|
238
|
+
removeProfileId() {
|
|
239
|
+
this.user.profileId = null;
|
|
240
|
+
}
|
|
241
|
+
removeEmail() {
|
|
242
|
+
this.user.email = null;
|
|
243
|
+
}
|
|
244
|
+
removeAppVersion() {
|
|
245
|
+
this.user.appVersion = null;
|
|
246
|
+
}
|
|
247
|
+
removeBrowserName() {
|
|
248
|
+
this.user.browser.name = null;
|
|
249
|
+
}
|
|
250
|
+
removeBrowserVersion() {
|
|
251
|
+
this.user.browser.version = null;
|
|
252
|
+
}
|
|
253
|
+
removeOsName() {
|
|
254
|
+
this.user.os.name = null;
|
|
255
|
+
}
|
|
256
|
+
removeOsVersion() {
|
|
257
|
+
this.user.os.version = null;
|
|
258
|
+
}
|
|
259
|
+
removeGeoCountry() {
|
|
260
|
+
this.user.geo.country = null;
|
|
261
|
+
}
|
|
262
|
+
removeGeoCode() {
|
|
263
|
+
this.user.geo.code = null;
|
|
264
|
+
}
|
|
265
|
+
removeGeoState() {
|
|
266
|
+
this.user.geo.state = null;
|
|
267
|
+
}
|
|
268
|
+
removeGeoCity() {
|
|
269
|
+
this.user.geo.city = null;
|
|
270
|
+
}
|
|
271
|
+
removeGeoIp() {
|
|
272
|
+
this.user.geo.ip = null;
|
|
273
|
+
}
|
|
274
|
+
removeCustomProperty(key) {
|
|
275
|
+
if (!key || typeof key !== "string")
|
|
276
|
+
return;
|
|
277
|
+
delete this.user.custom[key];
|
|
159
278
|
}
|
|
160
279
|
};
|
|
161
280
|
|
|
@@ -1141,7 +1260,7 @@ function generateFilteredList(array, name) {
|
|
|
1141
1260
|
}
|
|
1142
1261
|
|
|
1143
1262
|
// package.json
|
|
1144
|
-
var version = "3.
|
|
1263
|
+
var version = "3.3.0";
|
|
1145
1264
|
|
|
1146
1265
|
// src/helpers/sdkVersion.js
|
|
1147
1266
|
var sdkVersion = version;
|
|
@@ -1175,11 +1294,11 @@ var Sigma = class {
|
|
|
1175
1294
|
ip: this.userData.ip || null,
|
|
1176
1295
|
email: this.userData.email || null,
|
|
1177
1296
|
appVersion: this.userData.appVersion || null,
|
|
1178
|
-
custom: this.userData.custom ||
|
|
1297
|
+
custom: this.userData.custom || {},
|
|
1179
1298
|
deviceCategory: this.userData.deviceCategory || null,
|
|
1180
1299
|
browser: this.userData.browser || this.sigmaUserData.getUserBrowser(this.userData.ua),
|
|
1181
1300
|
os: this.userData.os || this.sigmaUserData.getUserOs(this.userData.ua),
|
|
1182
|
-
geo: this.userData.geo ||
|
|
1301
|
+
geo: this.userData.geo || {},
|
|
1183
1302
|
domain: this.userData.domain || null,
|
|
1184
1303
|
url: this.userData.url || null,
|
|
1185
1304
|
query: this.userData.query || null,
|
|
@@ -1273,7 +1392,7 @@ var Sigma = class {
|
|
|
1273
1392
|
} else if (this.userData.geo) {
|
|
1274
1393
|
this.geoCache.set(sigmaGeoData, JSON.stringify(this.userData.geo));
|
|
1275
1394
|
} else {
|
|
1276
|
-
this.geoCache.set(sigmaGeoData, JSON.stringify({
|
|
1395
|
+
this.geoCache.set(sigmaGeoData, JSON.stringify({}));
|
|
1277
1396
|
}
|
|
1278
1397
|
}
|
|
1279
1398
|
recordLastUpdateInCache() {
|
|
@@ -1299,7 +1418,7 @@ var Sigma = class {
|
|
|
1299
1418
|
await this.getUserGeoData();
|
|
1300
1419
|
} catch {
|
|
1301
1420
|
if (!this.geoCache.get(sigmaGeoData)) {
|
|
1302
|
-
this.geoCache.set(sigmaGeoData, JSON.stringify({
|
|
1421
|
+
this.geoCache.set(sigmaGeoData, JSON.stringify({}));
|
|
1303
1422
|
}
|
|
1304
1423
|
errorMessages.APIRequestErrorGeoData.token = this.token;
|
|
1305
1424
|
errorMessages.APIRequestErrorGeoData.userData = JSON.stringify(this.userData);
|
|
@@ -1744,6 +1863,166 @@ var Sigma = class {
|
|
|
1744
1863
|
}
|
|
1745
1864
|
return isSuccessRule;
|
|
1746
1865
|
}
|
|
1866
|
+
clearCacheByKeys(keys) {
|
|
1867
|
+
for (const key in keys) {
|
|
1868
|
+
this.cache.remove(keys[key]);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
clearUserProperties() {
|
|
1872
|
+
this.clearCacheByKeys([
|
|
1873
|
+
sigmaUserId,
|
|
1874
|
+
sigmaDeviceId,
|
|
1875
|
+
sigmaProfileId,
|
|
1876
|
+
sigmaExpiration,
|
|
1877
|
+
sigmaExperiments
|
|
1878
|
+
]);
|
|
1879
|
+
this.sigmaUserData.removeInjectedProperties();
|
|
1880
|
+
}
|
|
1881
|
+
overwriteGeoCache(key, value) {
|
|
1882
|
+
const geoCache = this.geoCache.parse(sigmaGeoData);
|
|
1883
|
+
geoCache[key] = value;
|
|
1884
|
+
this.geoCache.set(sigmaGeoData, JSON.stringify(geoCache));
|
|
1885
|
+
}
|
|
1886
|
+
editUserProperties() {
|
|
1887
|
+
return {
|
|
1888
|
+
setUserId: (userId) => {
|
|
1889
|
+
this.sigmaUserData.setUserId(userId);
|
|
1890
|
+
this.cache.set(sigmaUserId, userId);
|
|
1891
|
+
return this.editUserProperties();
|
|
1892
|
+
},
|
|
1893
|
+
setDeviceId: (deviceId) => {
|
|
1894
|
+
this.sigmaUserData.setDeviceId(deviceId);
|
|
1895
|
+
this.cache.set(sigmaDeviceId, deviceId);
|
|
1896
|
+
return this.editUserProperties();
|
|
1897
|
+
},
|
|
1898
|
+
setProfileId: (profileId) => {
|
|
1899
|
+
this.sigmaUserData.setProfileId(profileId);
|
|
1900
|
+
this.cache.set(sigmaProfileId, profileId);
|
|
1901
|
+
return this.editUserProperties();
|
|
1902
|
+
},
|
|
1903
|
+
setEmail: (email) => {
|
|
1904
|
+
this.sigmaUserData.setEmail(email);
|
|
1905
|
+
return this.editUserProperties();
|
|
1906
|
+
},
|
|
1907
|
+
setAppVersion: (appVersion) => {
|
|
1908
|
+
this.sigmaUserData.setAppVersion(appVersion);
|
|
1909
|
+
return this.editUserProperties();
|
|
1910
|
+
},
|
|
1911
|
+
setBrowserName: (browserName) => {
|
|
1912
|
+
this.sigmaUserData.setBrowserName(browserName);
|
|
1913
|
+
return this.editUserProperties();
|
|
1914
|
+
},
|
|
1915
|
+
setBrowserVersion: (browserVersion) => {
|
|
1916
|
+
this.sigmaUserData.setBrowserVersion(browserVersion);
|
|
1917
|
+
return this.editUserProperties();
|
|
1918
|
+
},
|
|
1919
|
+
setOsName: (osName) => {
|
|
1920
|
+
this.sigmaUserData.setOsName(osName);
|
|
1921
|
+
return this.editUserProperties();
|
|
1922
|
+
},
|
|
1923
|
+
setOsVersion: (osVersion) => {
|
|
1924
|
+
this.sigmaUserData.setOsVersion(osVersion);
|
|
1925
|
+
return this.editUserProperties();
|
|
1926
|
+
},
|
|
1927
|
+
setGeoCountry: (country) => {
|
|
1928
|
+
this.sigmaUserData.setGeoCountry(country);
|
|
1929
|
+
this.overwriteGeoCache("country", country);
|
|
1930
|
+
return this.editUserProperties();
|
|
1931
|
+
},
|
|
1932
|
+
setGeoCode: (code) => {
|
|
1933
|
+
this.sigmaUserData.setGeoCode(code);
|
|
1934
|
+
this.overwriteGeoCache("code", code);
|
|
1935
|
+
return this.editUserProperties();
|
|
1936
|
+
},
|
|
1937
|
+
setGeoState: (state) => {
|
|
1938
|
+
this.sigmaUserData.setGeoState(state);
|
|
1939
|
+
this.overwriteGeoCache("state", state);
|
|
1940
|
+
return this.editUserProperties();
|
|
1941
|
+
},
|
|
1942
|
+
setGeoCity: (city) => {
|
|
1943
|
+
this.sigmaUserData.setGeoCity(city);
|
|
1944
|
+
this.overwriteGeoCache("city", city);
|
|
1945
|
+
return this.editUserProperties();
|
|
1946
|
+
},
|
|
1947
|
+
setGeoIp: (ip) => {
|
|
1948
|
+
this.sigmaUserData.setGeoIp(ip);
|
|
1949
|
+
this.overwriteGeoCache("ip", ip);
|
|
1950
|
+
return this.editUserProperties();
|
|
1951
|
+
},
|
|
1952
|
+
setCustomProperty: (key, value) => {
|
|
1953
|
+
this.sigmaUserData.setCustomProperty(key, value);
|
|
1954
|
+
return this.editUserProperties();
|
|
1955
|
+
},
|
|
1956
|
+
removeUserId: () => {
|
|
1957
|
+
this.sigmaUserData.removeUserId();
|
|
1958
|
+
this.cache.remove(sigmaUserId);
|
|
1959
|
+
return this.editUserProperties();
|
|
1960
|
+
},
|
|
1961
|
+
removeDeviceId: () => {
|
|
1962
|
+
this.sigmaUserData.removeDeviceId();
|
|
1963
|
+
this.cache.remove(sigmaDeviceId);
|
|
1964
|
+
return this.editUserProperties();
|
|
1965
|
+
},
|
|
1966
|
+
removeProfileId: () => {
|
|
1967
|
+
this.sigmaUserData.removeProfileId();
|
|
1968
|
+
this.cache.remove(sigmaProfileId);
|
|
1969
|
+
return this.editUserProperties();
|
|
1970
|
+
},
|
|
1971
|
+
removeAppVersion: () => {
|
|
1972
|
+
this.sigmaUserData.removeAppVersion();
|
|
1973
|
+
return this.editUserProperties();
|
|
1974
|
+
},
|
|
1975
|
+
removeBrowserName: () => {
|
|
1976
|
+
this.sigmaUserData.removeBrowserName();
|
|
1977
|
+
return this.editUserProperties();
|
|
1978
|
+
},
|
|
1979
|
+
removeBrowserVersion: () => {
|
|
1980
|
+
this.sigmaUserData.removeBrowserVersion();
|
|
1981
|
+
return this.editUserProperties();
|
|
1982
|
+
},
|
|
1983
|
+
removeEmail: () => {
|
|
1984
|
+
this.sigmaUserData.removeEmail();
|
|
1985
|
+
return this.editUserProperties();
|
|
1986
|
+
},
|
|
1987
|
+
removeOsName: () => {
|
|
1988
|
+
this.sigmaUserData.removeOsName();
|
|
1989
|
+
return this.editUserProperties();
|
|
1990
|
+
},
|
|
1991
|
+
removeOsVersion: () => {
|
|
1992
|
+
this.sigmaUserData.removeOsVersion();
|
|
1993
|
+
return this.editUserProperties();
|
|
1994
|
+
},
|
|
1995
|
+
removeGeoCountry: () => {
|
|
1996
|
+
this.sigmaUserData.removeGeoCountry();
|
|
1997
|
+
this.overwriteGeoCache("country", null);
|
|
1998
|
+
return this.editUserProperties();
|
|
1999
|
+
},
|
|
2000
|
+
removeGeoCode: () => {
|
|
2001
|
+
this.sigmaUserData.removeGeoCode();
|
|
2002
|
+
this.overwriteGeoCache("code", null);
|
|
2003
|
+
return this.editUserProperties();
|
|
2004
|
+
},
|
|
2005
|
+
removeGeoState: () => {
|
|
2006
|
+
this.sigmaUserData.removeGeoState();
|
|
2007
|
+
this.overwriteGeoCache("state", null);
|
|
2008
|
+
return this.editUserProperties();
|
|
2009
|
+
},
|
|
2010
|
+
removeGeoCity: () => {
|
|
2011
|
+
this.sigmaUserData.removeGeoCity();
|
|
2012
|
+
this.overwriteGeoCache("city", null);
|
|
2013
|
+
return this.editUserProperties();
|
|
2014
|
+
},
|
|
2015
|
+
removeGeoIp: () => {
|
|
2016
|
+
this.sigmaUserData.removeGeoIp();
|
|
2017
|
+
this.overwriteGeoCache("ip", null);
|
|
2018
|
+
return this.editUserProperties();
|
|
2019
|
+
},
|
|
2020
|
+
removeCustomProperty: (key) => {
|
|
2021
|
+
this.sigmaUserData.removeCustomProperty(key);
|
|
2022
|
+
return this.editUserProperties();
|
|
2023
|
+
}
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
1747
2026
|
};
|
|
1748
2027
|
var sigma_default = Sigma;
|
|
1749
2028
|
// Annotate the CommonJS export names for ESM import in node:
|