open-feature / js-sdk-contrib

OpenFeature Providers and Hooks for JavaScript
https://openfeature.dev
Apache License 2.0
37 stars 37 forks source link

[FEATURE] Change fractional custom op from percentage-based to relative weighting. #946

Closed toddbaert closed 4 months ago

toddbaert commented 4 months ago

Requirements

Currently, the fractional operator in the in-process provider is percentage-based; meaning you must specify the relative distribution of the variants in terms of a percentage. Consistent with flagd, we should change this instead to be a relative weight, meaning that the integers do not need to sum to 100. For example, this fractional:

"fractional": [
          [
            "red",
            25
          ],
          [
            "blue",
            25
          ],
          [
            "green",
            25
          ],
          [
            "grey",
            25
          ]
        ]

Would remain valid, but could also be expressed as:

"fractional": [
          [
            "red",
            1
          ],
          [
            "blue",
            1
          ],
          [
            "green",
            1
          ],
          [
            "grey",
            1
          ]
        ]

See issue and PR in Go/flagd.