( feature: string, value: unknown, )
| 243 | * change the model until the next periodic refresh. |
| 244 | */ |
| 245 | export function setGrowthBookConfigOverride( |
| 246 | feature: string, |
| 247 | value: unknown, |
| 248 | ): void { |
| 249 | if (process.env.USER_TYPE !== 'ant') return |
| 250 | try { |
| 251 | saveGlobalConfig(c => { |
| 252 | const current = c.growthBookOverrides ?? {} |
| 253 | if (value === undefined) { |
| 254 | if (!(feature in current)) return c |
| 255 | const { [feature]: _, ...rest } = current |
| 256 | if (Object.keys(rest).length === 0) { |
| 257 | const { growthBookOverrides: __, ...configWithout } = c |
| 258 | return configWithout |
| 259 | } |
| 260 | return { ...c, growthBookOverrides: rest } |
| 261 | } |
| 262 | if (isEqual(current[feature], value)) return c |
| 263 | return { ...c, growthBookOverrides: { ...current, [feature]: value } } |
| 264 | }) |
| 265 | // Subscribers do their own change detection (see onGrowthBookRefresh docs), |
| 266 | // so firing on a no-op write is fine. |
| 267 | refreshed.emit() |
| 268 | } catch (e) { |
| 269 | logError(e) |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | export function clearGrowthBookConfigOverrides(): void { |
| 274 | if (process.env.USER_TYPE !== 'ant') return |
nothing calls this directly
no test coverage detected