Skip to content

Conversation

@kaushalkapasi
Copy link
Contributor

@kaushalkapasi kaushalkapasi commented Jun 3, 2025

  • feat: adds Evaluation Reasons for JS Bucketing shared library as eval on the Feature & Variable
  • chores:
    • updates tests to verify proper eval reasons are reported
    • update test data (filters) to properly use Country as 2 letter codes (ISO-3166)
    • remove unsupported IP address filter
    • only return reasonDetails if the evaluation is truthy
    • streamline Eval Reason Details into an Enum
  • fix: update JS & NodeJS SDKs to properly parse variable.eval from Bucketed User Configurations
  • chore: update OpenFeature Providers for DevCycle SDKs to map variable.eval?.reason to reason for evaluation reasons (aka if DevCycle provides an evaluation reason, pass it along to the OpenFeature Provider)
  • fix: re-adds the evalReason field to the SDKVariable type definition to allow NodeJS builds to work, this will be removed during the WASM Bucketing lib changes

@vercel
Copy link

vercel bot commented Jun 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
js-sdks-web-elements ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 9:29pm
js-sdks-with-provider ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 9:29pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
js-sdks-next-js-page-router ⬜️ Ignored (Inspect) Jun 5, 2025 9:29pm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces evaluation reasons for JS bucketing by adding new enums and updating the types to propagate evaluation details during bucketing and segmentation. Key changes include the removal of the unsupported IP filter, the addition of EVAL_REASONS, EVAL_REASON_DETAILS, and EvalReason types in the SDK API, and extensive updates to segmentation and bucketing logic, including corresponding updates to tests to reflect the new output structure.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/shared/types/src/types/config/models/audience.ts Removed the unsupported IP filter by deleting the ip field from UserSubType.
lib/shared/types/src/types/apis/sdk/clientSDKAPI.ts Added new enums (DEFAULT_REASONS, EVAL_REASONS, EVAL_REASON_DETAILS) and updated evalReason typings.
lib/shared/bucketing/src/segmentation.ts Refactored evaluateOperator to return an object with result and reasonDetails; updated filter evaluation logic.
lib/shared/bucketing/src/bucketing.ts Updated bucketing functions to return variation decisions along with evalReasons based on rollout and targeting status.
lib/shared/bucketing/tests/* Adjusted test assertions to match the new object shape with evaluation reason details.
lib/shared/bucketing-test-data/src/data/testData.ts Updated country codes to conform with ISO-3166 two-letter formats.
Comments suppressed due to low confidence (1)

lib/shared/bucketing/src/bucketing.ts:80

  • In decideTargetVariation, the lower bound for each variation check is always 0 because previousDistributionIndex is never updated inside the loop. Consider updating previousDistributionIndex at the end of each iteration (e.g. setting previousDistributionIndex = distributionIndex) to accurately reflect each variation's range.
const previousDistributionIndex = 0

const result = checkStringsFilter(data.country, filter)
return {
result,
reasonDetails: result ? EVAL_REASON_DETAILS.COUNTRY : undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would the result be undefined here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if result is false, that means the user did not meet the criteria to be bucketed into the feature, therefore we don't want to set the reasonDetails property

deviceModel: (data, filter) => checkStringsFilter(data.deviceModel, filter),
platform: (data, filter) => checkStringsFilter(data.platform, filter),
country: (data, filter) => {
const result = checkStringsFilter(data.country, filter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check the comparator for the string filters?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or is the idea to let the user know of the field that they are getting evaluated by and not the actual targeting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the field(s) that the user matched to get bucketed into a given variation

…lReasons field to allow node SDK builds as wasm bucketing still depends on it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants