Skip to content

feat: allow computed fractional bucket variants #1988

Open

Description

@toddbaert

A fractional bucket variant can be any JSON Logic expression, not only a literal:

{
  "state": "ENABLED",
  "defaultVariant": "blue",
  "variants": {
    "red": "#FF0000",
    "blue": "#0000FF"
  },
  "targeting": {
    "fractional": [
      [{ "cat": ["r", "ed"] }, 50],
      ["blue", 50]
    ]
  }
}
  • Evaluate each variant expression once, before bucketing, and return the result for the selected bucket.
  • Don't reject a variant based on its result type. Pass the result through, and let the resolver handle it like any other targeting result.
  • Bucketing doesn't change; it depends only on the bucketing value and the weights.

This may already work, or only need a variant type check relaxed. Either way, please add a test.

Why: this allows the new resolve operator as a bucket variant (e.g. [{ "resolve": ["red", "SPLIT"] }, 50]), so each bucket can set its own reason and metadata.

References:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions