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: "short", discount: 5, purchaseButtonLabel: "Purchase" }, data: { flags: { ads: true, checkout: "short", discount: 5, purchaseButtonLabel: "Purchase" }, resolvedVariantIds: { ads: "on", checkout: "on", discount: "on", purchaseButtonLabel: "on" }, visitor: { key: "4GGI1NmOxUdrvadCOiwvn" } }, error: null, fetching: false, settled: true, visitorKey: "4GGI1NmOxUdrvadCOiwvn" }
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.