fix: return flag state after evaluation
When no percentage or rule is applied during evaluation, return the state of the flag instead of a fixed false.
Problem
When using the getFlag method on the Client class, the flag is evaluated. If no percentage or rules are present on the flag, a fixed false is returned instead of the enabled property of the flag.
Example:
import { Client, type Environment } from "@upstash/edge-flags";
const client = new Client({
redis: Redis.fromEnv(),
environment: (process.env.VERCEL_ENV as Environment) ?? "development",
});
const flag = await client.getFlag("flag-name", {});
// ^ Returns false if no percentage or rules are defined
Solution
Return flag.enabled instead of false at the end of the evaluation.
@reinvanhaaren is attempting to deploy a commit to the Upstash Team on Vercel.
A member of the Team first needs to authorize it.
@chronark hi Andreas. Is it possible to take a look at my pull request? I think many will benefit from this small change.
I no longer work for Upstash but it looks good
cc @enesakar
Hey @reinvanhaaren, sorry about missing your PR in this repo. Thanks a lot for the contribution 🙏