You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add sample feature flagging system to next.js template (#259)
## Changes
- Add a service class for retrieving flags from evidently
- Add example consuming the flags
- Updated docs
- tests
## Context for reviewers
- This is followup / related work alongside last week's platform infra
changes.
## Testing
- I'd love some help testing this out against the platform infra.
---------
Co-authored-by: Sawyer <[email protected]>
Copy file name to clipboardexpand all lines: app/src/i18n/messages/en-US/index.ts
+4
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,10 @@ export const messages = {
19
19
intro:
20
20
"This is a template for a React web application using the <LinkToNextJs>Next.js framework</LinkToNextJs>.",
21
21
body: "This is template includes:<ul><li>Framework for server-side rendered, static, or hybrid React applications</li><li>TypeScript and React testing tools</li><li>U.S. Web Design System for themeable styling and a set of common components</li><li>Type checking, linting, and code formatting tools</li><li>Storybook for a frontend workshop environment</li></ul>",
22
+
feature_flagging:
23
+
"The template includes AWS Evidently for feature flagging. Toggle flag to see the content below change:",
24
+
flag_off: "Flag is disabled",
25
+
flag_on: "Flag is enabled",
22
26
formatting:
23
27
"The template includes an internationalization library with basic formatters built-in. Such as numbers: { amount, number, currency }, and dates: { isoDate, date, long}.",
-[AWS Evidently](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Evidently.html) is used for feature flagging
4
+
- For more information about the decision-making behind using Evidently, [this infra ADR is available](https://github.com/navapbc/template-infra/blob/68b2db42d06198cb070b0603e63a930db346309f/docs/decisions/infra/0010-feature-flags-system-design.md)
5
+
- Additional documentation of the feature flagging solution is available in [infra docs](https://github.com/navapbc/template-infra/blob/main/docs/feature-flags.md)
6
+
7
+
## How it works
8
+
9
+
1.`services/feature-flags/FeatureFlagManager` provides a service layer to interact with AWS Evidently endpoints. For example, class method `isFeatureEnabled` calls out to Evidently to retrieve a feature flag value we can then return to the client
10
+
1. Pages can call `isFeatureEnabled` from Next.js server side code and return the feature flag value to components as props.
11
+
12
+
## Local development
13
+
14
+
Out-of-the-box, local calls where `FEATURE_FLAGS_PROJECT` environment variable is unset will fall back to use `LocalFeatureFlagManager` which defaults flag values to `false`.
15
+
16
+
If you want to test Evidently locally, use your AWS IAM credentials. Once you set `FEATURE_FLAGS_PROJECT` and the AWS environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_REGION`) in `app/.env.local`, calls to Evidently will succeed.
17
+
18
+
## Creating a new feature flag
19
+
20
+
To create a new feature flag, update `/infra/[app_name]/app-config/main.tf`. More information available in infra repository [docs](https://github.com/navapbc/template-infra/blob/main/docs/feature-flags.md).
21
+
22
+
## Toggling feature flags
23
+
24
+
Toggle feature flags via the AWS Console GUI. More information [here](https://github.com/navapbc/template-infra/blob/main/docs/feature-flags.md#managing-feature-releases-and-partial-rollouts-via-aws-console).
0 commit comments