Targeting by Traits

This demo is easiest to understand if you open its source code in a parallel tab.

Source code

This demo shows how to use @happykit/flags for targeting by traits.

You can pass any traits into the flag evaluation. These traits can then be used by the rules defined in your flags. This allows you to resolve flags differently based on the provided traits.

Traits can be related to the visitor, to the authenticated user or to anything else. You can pass any traits you want. Use the traits in your HappyKit flag rules to resolve the flag to different variants based on the passed traits.

Render #1 (Current render)
{ flags: { ads: true, checkout: "medium", discount: 15, purchaseButtonLabel: "Add to cart" }, data: { flags: { ads: true, checkout: "medium", discount: 15, purchaseButtonLabel: "Add to cart" }, visitor: { key: "xo8_bBNDjJ-_C9yf5n4XW" } }, error: null, fetching: false, settled: true, visitorKey: "xo8_bBNDjJ-_C9yf5n4XW" }

Note that aside from traits, HappyKit also has the concepts of a visitor and a user. These three concepts are all independent of each other.