Closed dferber90 closed 2 years ago
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/happykit/flags/H4dFcBQEM8WhB985W9j2K1AqWmr9
✅ Preview: https://flags-git-remove-static-happykit.vercel.app
Context: Feature flags can be evaluated on behalf of a user (server-side rendering) or without the context of a user (usually during static site generation). HappyKit needs a way to distinguish that and was previously sending
static
in the request body. This is no longer necessary as we can simply rely onvisitorKey
instead.visitorKey
will only be present when evaluating flags on behalf of a user.Knowing whether flags were evaluated on behalf of a user or without the context of a user allows the
@happykit/flags/client
to decide whether to reevaluate the flags on mount or not (reevaluate if novisitorKey
was present in the initial response).If
visitorKey
is not present in the request, novisitorKey
will get generated by HappyKit's API.The API now purely relies on
visitorKey
, and no longer onstatic
. IfvisitorKey
is present in the API response, the client will generate avisitorKey
and reevaluate the flags with that.@happykit/flags
should treat all responses without avisitorKey
as static sites.@happykit/flags
needs to generate avisitorKey
in case novisitorKey
is present and reevaluate flags on behalf of a specific visitor (a non-static site).All evaluations on behalf of a user (for server-side rendering) generate a
visitorKey
themselves (or use the existingvisitorKey
if present) and invoke the HappyKit API with it.getFlags
andgetEdgeFlags
do this for you.