flagsmith icon indicating copy to clipboard operation
flagsmith copied to clipboard

feat: Introduce the SDK Evaluation Context schema

Open khvn26 opened this issue 1 year ago • 6 comments

Thanks for submitting a PR! Please check the boxes below:

Contributes to #4413.

  • [ ] I have added information to docs/ if required so people know about the feature!
  • [x] I have filled in the "Changes" section below?
  • [x] I have filled in the "How did you test this code" section below?
  • [x] I have used a Conventional Commit title for this Pull Request

Changes

The following is a proposed Flagsmith Evaluation Context schema JSON Schema definition.

Notes

  • IdentityEvaluationContext.traits is a mapping of trait keys to a TraitEvaluationContext | null union. In case a null is provided, we assume intent to delete the previously persisted trait.
  • TraitEvaluationContext.value can only be a string now.
  • We now have a TraitEvaluationContext.type enum field designating the trait value type. For now it will support an SDK-side mapping layer. It's expected that the v2 SDK API should support it in the future.

How did you test this code?

This is a documentation change, but I'm verifying the schema against a validator.

khvn26 avatar Jul 29 '24 17:07 khvn26

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Aug 6, 2024 9:16pm
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Aug 6, 2024 9:16pm
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Aug 6, 2024 9:16pm

vercel[bot] avatar Jul 29 '24 17:07 vercel[bot]

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-4414 Finished :white_check_mark: Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-4414 Finished :white_check_mark: Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-4414 Finished :white_check_mark: Results :white_check_mark:
ghcr.io/flagsmith/flagsmith-api:pr-4414 Finished :white_check_mark: Results :white_check_mark:
ghcr.io/flagsmith/flagsmith:pr-4414 Finished :white_check_mark: Results :white_check_mark:
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4414 Finished :white_check_mark: Results :white_check_mark:

github-actions[bot] avatar Jul 29 '24 17:07 github-actions[bot]

Uffizzi Ephemeral Environment deployment-54754

:cloud: https://app.uffizzi.com/github.com/Flagsmith/flagsmith/pull/4414

:page_facing_up: View Application Logs etc.

What is Uffizzi? Learn more!

github-actions[bot] avatar Jul 29 '24 17:07 github-actions[bot]

@khvn26 I love the idea of a schema. I would like to see examples of how this schema would be used. While I think the current schema is complete and clear, I think we could simplify the structure of some of the contexts, but that would be clearer if we could have some implementation examples of the schema.

novakzaballa avatar Jul 31 '24 13:07 novakzaballa

@novakzaballa One thing I could do to demonstrate is to go ahead and add it for JS and Golang SDK transient ids/traits PRs. You'll be able to review the schema with those implementations in consideration.

khvn26 avatar Jul 31 '24 13:07 khvn26

@novakzaballa One thing I could do to demonstrate is to go ahead and add it for JS and Golang SDK transient ids/traits PRs. You'll be able to review the schema with those implementations in consideration.

Let's do that @khvn26 . Some examples I generated look good to me and we can always optimize if we see an opportunity while we move forward. I'll approve the PR. Nice job!

novakzaballa avatar Jul 31 '24 13:07 novakzaballa