import { isEnabled, getVariant, evaluateAll } from "@pylonsync/feature-flags";
const flags = {
"new-onboarding": {
type: "boolean",
default: true,
rollout: { percent: 25 },
targeting: [
{ value: true, when: [{ property: "plan", op: "eq", value: "enterprise" }] },
],
},
"ai-model": {
type: "multivariate",
default: "gpt-4",
variants: [
{ name: "gpt-4", weight: 80, payload: { maxTokens: 4096 } },
{ name: "claude-opus", weight: 20, payload: { maxTokens: 8192 } },
],
},
} as const;
const ctx = { userId: "u_42", properties: { plan: "pro" } };
isEnabled(flags, "new-onboarding", ctx); // boolean
getVariant(flags, "ai-model", ctx); // "gpt-4" | "claude-opus"
evaluateAll(flags, ctx); // { "new-onboarding": true, "ai-model": {maxTokens: 4096} }