expf-sigma-node.js 3.3.4 → 3.3.5
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 +46 -63
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.5",
|
|
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
|
@@ -1268,7 +1268,7 @@ function generateFilteredList(array, name) {
|
|
|
1268
1268
|
}
|
|
1269
1269
|
|
|
1270
1270
|
// package.json
|
|
1271
|
-
var version = "3.3.
|
|
1271
|
+
var version = "3.3.5";
|
|
1272
1272
|
|
|
1273
1273
|
// src/helpers/sdkVersion.js
|
|
1274
1274
|
var sdkVersion = version;
|
|
@@ -1663,7 +1663,7 @@ var Sigma = class {
|
|
|
1663
1663
|
userValue,
|
|
1664
1664
|
targets.conditions[index].value,
|
|
1665
1665
|
targets.conditions[index].condition_sign,
|
|
1666
|
-
this.sigmaUserData.user.
|
|
1666
|
+
this.sigmaUserData.user.date,
|
|
1667
1667
|
this.sigmaUserData.user.time
|
|
1668
1668
|
)
|
|
1669
1669
|
);
|
|
@@ -1876,7 +1876,7 @@ var Sigma = class {
|
|
|
1876
1876
|
userValue,
|
|
1877
1877
|
conditions[i].value,
|
|
1878
1878
|
conditions[i].condition_sign,
|
|
1879
|
-
this.sigmaUserData.user.
|
|
1879
|
+
this.sigmaUserData.user.date,
|
|
1880
1880
|
this.sigmaUserData.user.time
|
|
1881
1881
|
)
|
|
1882
1882
|
);
|
|
@@ -2110,25 +2110,12 @@ var Sigma = class {
|
|
|
2110
2110
|
console.warn(`Sigma warn: Experiment ${experimentId} has not group with index ${groupIndex}`);
|
|
2111
2111
|
return;
|
|
2112
2112
|
}
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
return;
|
|
2116
|
-
}
|
|
2117
|
-
if (splitById && this.userData[splitById] && !groupInExperiment.forced_user_list.includes(String(this.userData[splitById]))) {
|
|
2113
|
+
this.clearForcedList(experiment, splitById);
|
|
2114
|
+
if (this.userData[splitById] && !groupInExperiment.forced_user_list.includes(String(this.userData[splitById]))) {
|
|
2118
2115
|
groupInExperiment.forced_user_list.push(String(this.userData[splitById]));
|
|
2119
2116
|
}
|
|
2120
2117
|
} else if (!groupIndex) {
|
|
2121
|
-
|
|
2122
|
-
for (const group of experiment.groups) {
|
|
2123
|
-
if (splitById && group.forced_user_list.includes(String(this.userData[splitById]))) {
|
|
2124
|
-
isUserInForcedGroup = true;
|
|
2125
|
-
break;
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
if (isUserInForcedGroup) {
|
|
2129
|
-
console.warn(`Sigma warn: User is already group in experiment ${experimentId}. You need to exclude first then run method again`);
|
|
2130
|
-
return;
|
|
2131
|
-
}
|
|
2118
|
+
this.clearForcedList(experiment, splitById);
|
|
2132
2119
|
if (this.userData[splitById] && !experiment.forced_user_list.includes(String(this.userData[splitById]))) {
|
|
2133
2120
|
experiment.forced_user_list.push(String(this.userData[splitById]));
|
|
2134
2121
|
}
|
|
@@ -2136,68 +2123,64 @@ var Sigma = class {
|
|
|
2136
2123
|
if (!this.cache.get(sigmaForcedExperiments)) {
|
|
2137
2124
|
this.cache.set(sigmaForcedExperiments, JSON.stringify([{ experimentId, groupIndex }]));
|
|
2138
2125
|
} else {
|
|
2139
|
-
const forcedExperiments =
|
|
2140
|
-
|
|
2126
|
+
const forcedExperiments = this.cache.parse(sigmaForcedExperiments);
|
|
2127
|
+
const foundingForcedExperiment = forcedExperiments.find((el) => el.experimentId === experimentId);
|
|
2128
|
+
if (!foundingForcedExperiment) {
|
|
2141
2129
|
forcedExperiments.push({ experimentId, groupIndex });
|
|
2142
2130
|
this.cache.set(sigmaForcedExperiments, JSON.stringify(forcedExperiments));
|
|
2131
|
+
} else if (typeof groupIndex === "number" && groupIndex >= 0 && foundingForcedExperiment) {
|
|
2132
|
+
foundingForcedExperiment.groupIndex = groupIndex;
|
|
2133
|
+
this.cache.set(sigmaForcedExperiments, JSON.stringify(forcedExperiments));
|
|
2134
|
+
} else if (!groupIndex && foundingForcedExperiment) {
|
|
2135
|
+
foundingForcedExperiment.groupIndex = groupIndex;
|
|
2136
|
+
this.cache.set(sigmaForcedExperiments, JSON.stringify(forcedExperiments));
|
|
2143
2137
|
}
|
|
2144
2138
|
}
|
|
2145
2139
|
this.cache.set(sigmaDataFile, JSON.stringify(sigmaDataLs));
|
|
2146
2140
|
}
|
|
2147
|
-
|
|
2148
|
-
if (
|
|
2141
|
+
clearForcedList(experiment, splitById) {
|
|
2142
|
+
if (experiment.forced_user_list.includes(String(this.userData[splitById]))) {
|
|
2143
|
+
experiment.forced_user_list = experiment.forced_user_list.filter((el) => String(el) !== String(this.userData[splitById]));
|
|
2144
|
+
}
|
|
2145
|
+
for (const group of experiment.groups) {
|
|
2146
|
+
if (group.forced_user_list.includes(String(this.userData[splitById]))) {
|
|
2147
|
+
group.forced_user_list = group.forced_user_list.filter((el) => String(el) !== String(this.userData[splitById]));
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
async excludeForceUser(experimentId) {
|
|
2152
|
+
if (!experimentId || !this.cache.get(sigmaDataFile) || !this.cache.get(sigmaForcedExperiments))
|
|
2149
2153
|
return;
|
|
2150
2154
|
const sigmaDataLs = this.cache.parse(sigmaDataFile);
|
|
2151
2155
|
if (!sigmaDataLs || !sigmaDataLs.experiments)
|
|
2152
2156
|
return;
|
|
2153
2157
|
let experiment = sigmaDataLs.experiments.find((exp) => exp.name === experimentId);
|
|
2154
|
-
if (!experiment)
|
|
2158
|
+
if (!experiment) {
|
|
2159
|
+
console.warn(`Sigma warn: Experiment ${experimentId} not found`);
|
|
2155
2160
|
return;
|
|
2156
|
-
if (!Object.keys(this.userData).includes(experiment.split_by))
|
|
2157
|
-
return;
|
|
2158
|
-
const splitById = Object.keys(this.userData).find((id) => id === experiment.split_by);
|
|
2159
|
-
if (experiment.forced_user_list.length && experiment.forced_user_list.includes(String(this.userData[splitById]))) {
|
|
2160
|
-
experiment.forced_user_list = experiment.forced_user_list.filter((el) => el !== String(this.userData[splitById]));
|
|
2161
2161
|
}
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
group.forced_user_list = group.forced_user_list.filter((el) => el !== String(this.userData[splitById]));
|
|
2166
|
-
}
|
|
2162
|
+
if (!Object.keys(this.userData).includes(experiment.split_by)) {
|
|
2163
|
+
console.warn(`Sigma warn: ${experiment.split_by} is missing in userData`);
|
|
2164
|
+
return;
|
|
2167
2165
|
}
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2166
|
+
let forcedExperiments = this.cache.parse(sigmaForcedExperiments);
|
|
2167
|
+
if (!forcedExperiments.find((el) => el.experimentId === experimentId))
|
|
2168
|
+
return;
|
|
2169
|
+
forcedExperiments = forcedExperiments.filter((el) => el.experimentId !== experimentId);
|
|
2170
|
+
if (forcedExperiments.length > 0) {
|
|
2171
|
+
this.cache.set(sigmaForcedExperiments, JSON.stringify(forcedExperiments));
|
|
2172
|
+
} else {
|
|
2173
|
+
this.cache.remove(sigmaForcedExperiments);
|
|
2176
2174
|
}
|
|
2177
|
-
this.cache.set(
|
|
2175
|
+
this.cache.set(sigmaHash, "");
|
|
2176
|
+
await this.saveToCache();
|
|
2178
2177
|
}
|
|
2179
|
-
excludeForceUserAll() {
|
|
2180
|
-
if (!this.cache.get(sigmaDataFile))
|
|
2178
|
+
async excludeForceUserAll() {
|
|
2179
|
+
if (!this.cache.get(sigmaDataFile) || !this.cache.get(sigmaForcedExperiments))
|
|
2181
2180
|
return;
|
|
2182
|
-
const sigmaDataLs = this.cache.parse(sigmaDataFile);
|
|
2183
|
-
if (!sigmaDataLs || !sigmaDataLs.experiments)
|
|
2184
|
-
return;
|
|
2185
|
-
for (const experiment of sigmaDataLs.experiments) {
|
|
2186
|
-
if (!Object.keys(this.userData).includes(experiment.split_by))
|
|
2187
|
-
continue;
|
|
2188
|
-
const splitById = Object.keys(this.userData).find((id) => id === experiment.split_by);
|
|
2189
|
-
if (experiment.forced_user_list.length && experiment.forced_user_list.includes(String(this.userData[splitById]))) {
|
|
2190
|
-
experiment.forced_user_list = experiment.forced_user_list.filter((el) => el !== String(this.userData[splitById]));
|
|
2191
|
-
}
|
|
2192
|
-
const groups = experiment.groups;
|
|
2193
|
-
for (const group of groups) {
|
|
2194
|
-
if (group.forced_user_list.length && group.forced_user_list.includes(String(this.userData[splitById]))) {
|
|
2195
|
-
group.forced_user_list = group.forced_user_list.filter((el) => el !== String(this.userData[splitById]));
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
}
|
|
2199
2181
|
this.cache.remove(sigmaForcedExperiments);
|
|
2200
|
-
this.cache.set(
|
|
2182
|
+
this.cache.set(sigmaHash, "");
|
|
2183
|
+
await this.saveToCache();
|
|
2201
2184
|
}
|
|
2202
2185
|
checkForceExperiments() {
|
|
2203
2186
|
if (!this.cache.get(sigmaForcedExperiments))
|