(experimentId: ExperimentId)
| 175 | } |
| 176 | |
| 177 | getExperimentValue(experimentId: ExperimentId): ExperimentValue { |
| 178 | assert(experimentId in EXPERIMENTS, `Unknown experimentId: ${experimentId}`); |
| 179 | |
| 180 | if (!this.isExperimentSupported(experimentId)) { |
| 181 | return { value: null, source: "disabled" }; |
| 182 | } |
| 183 | |
| 184 | const override = this.overrides.get(experimentId); |
| 185 | if (override !== undefined) { |
| 186 | if (this.isRemoteEvaluationEnabled()) { |
| 187 | this.maybeRefreshInBackground(experimentId); |
| 188 | } |
| 189 | return { value: override, source: "override" }; |
| 190 | } |
| 191 | |
| 192 | if (!this.isRemoteEvaluationEnabled()) { |
| 193 | return { value: null, source: "disabled" }; |
| 194 | } |
| 195 | |
| 196 | const cached = this.cachedVariants.get(experimentId); |
| 197 | if (!cached) { |
| 198 | // No cached value yet. Fail closed, but kick off a background refresh. |
| 199 | this.maybeRefreshInBackground(experimentId); |
| 200 | return { value: null, source: "cache" }; |
| 201 | } |
| 202 | |
| 203 | this.maybeRefreshInBackground(experimentId); |
| 204 | return { value: cached.value, source: cached.source }; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Convert an experiment assignment to a boolean gate. |
no test coverage detected