happykit / flags

⛳️ Feature Flags for Next.js
https://happykit.dev
MIT License
1.01k stars 11 forks source link

remove static #19

Closed dferber90 closed 2 years ago

dferber90 commented 2 years ago

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 on visitorKey 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 no visitorKey was present in the initial response).


If visitorKey is not present in the request, no visitorKey will get generated by HappyKit's API.

The API now purely relies on visitorKey, and no longer on static. If visitorKey is present in the API response, the client will generate a visitorKey and reevaluate the flags with that.

@happykit/flags should treat all responses without a visitorKey as static sites. @happykit/flags needs to generate a visitorKey in case no visitorKey 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 existing visitorKey if present) and invoke the HappyKit API with it. getFlags and getEdgeFlags do this for you.

vercel[bot] commented 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