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: "Get it" }, data: { flags: { ads: true, checkout: "medium", discount: 15, purchaseButtonLabel: "Get it" }, resolvedVariantIds: { ads: "on", checkout: "off", discount: "1617854357561", purchaseButtonLabel: "1617982711642" }, visitor: { key: "6NtUUwgl9OV5LzNSlTfI-" } }, error: null, fetching: false, settled: true, visitorKey: "6NtUUwgl9OV5LzNSlTfI-" }
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.