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: "full", discount: 15, purchaseButtonLabel: "Purchase" }, data: { flags: { ads: true, checkout: "full", discount: 15, purchaseButtonLabel: "Purchase" }, resolvedVariantIds: { ads: "on", checkout: "1617854290624", discount: "1617854357561", purchaseButtonLabel: "on" }, visitor: { key: "oCCbEoE_7YSddJGO7XjFi" } }, error: null, fetching: false, settled: true, visitorKey: "oCCbEoE_7YSddJGO7XjFi" }

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.