Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #2695] opportunity and search toggle with feature flag env vars #3115

Merged
merged 16 commits into from
Dec 11, 2024

Conversation

doug-s-nava
Copy link
Collaborator

@doug-s-nava doug-s-nava commented Dec 5, 2024

Summary

Fixes #2695

Time to review: 30 mins

Changes proposed

The goal of the PR is the addition of two "kill switch" parameters that can be used to direct the search and opportunity pages, respectively, to a maintenance page. These parameters can be supplied either on the frontend via query params or feature flags admin panel, or via environment variables.

Setting flags via environment variables is a new functionality, so changes were made to the system to get this to work. Some deficiencies of the existing system were also patched up as part of this process.

Context for reviewers

Test Steps

  1. FEATURE_OPPORTUNITY_OFF=true FEATURE_SEARCH_OFF=true npm run dev on this branch
  2. visit http://localhost:3000/search
  3. VERIFY: maintenance page appears
  4. VERIFY: maintenance page matches designs and includes correct text from spec
  5. visit http://localhost:3000/opportunity/1
  6. VERIFY: maintenance page appears
  7. VERIFY: maintenance page matches designs and includes correct text from spec
  8. visit http://localhost:3000/search?_ff=searchOff%3Afalse
  9. VERIFY: search page appears
    1. visit http://localhost:3000/opportunity/1?_ff=opportunityOff%3Afalse
  10. VERIFY: opportunity page appears
  11. Repeat 2 - x but in faux prod mode with npm run build && FEATURE_OPPORTUNITY_OFF=true FEATURE_SEARCH_OFF=true npm start

Dockerized

I would like to be able to test the changes to the Dockerfile locally, but can't without creating a docker compose that runs the production Next build and start rather than next dev. I feel like that's out of scope for this change, so we should just deploy out to DEV and test there.

Additional information

Screenshots, GIF demos, code examples or output to help show the changes working as expected.

@doug-s-nava doug-s-nava force-pushed the dschrashun/2695-opportunity-kill-switch branch from be196a6 to 9f4febc Compare December 9, 2024 14:30
get featureFlags(): FeatureFlags {
return {
...this.defaultFeatureFlags,
...this.featureFlagsFromEnvironment,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this means that if a user in any way sets their cookie to override the flag, they'll be able to access search or opportunities

if (!this.isValidFeatureFlag(featureName)) {
throw new Error(`\`${featureName}\` is not a valid feature flag`);
}
const featureFlags = {
...this.featureFlags,
...this.featureFlagsCookie,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a change to the existing functionality - previously whenever we set the feature flags cookie it would enshrine the default feature flag values in the cookie, but that functionality conflicts with idea of honoring flags set in the environment and using cookies as an override. Setting a flag on the cookie should, in this case, only set the single flag value specified

@@ -8,7 +8,7 @@
"scripts": {
"all-checks": "npm run test && npm run lint && npm run ts:check && npm run build",
"build": "next build",
"dev": "next dev",
"dev": "NEW_RELIC_ENABLED=false next dev",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated but makes local development logs less busy

export const revalidate = 600; // invalidate ten minutes
export const dynamic = "force-dynamic";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly don't understand why this needs to be here since we are already including the generateStaticParams, but without the the production build fails to render the page due to the dependence on searchParams in the withFeatureFlag code

// This should be removed when the search page goes live, before May 2024
showSearchV0: true,
hideSearchV0: false,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need this? I changed it to a hide vs show variable to match the pattern here and allow us to more easily reason about feature flag effects

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could drop this at this point. Or we could try to generalize it as like searchBeta that we can keep rolling things out using and then remove the flag checks as we consider those things Released.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove it. When I turned it on locally it created a 500 error or the search page.

@doug-s-nava doug-s-nava changed the title Dschrashun/2695 opportunity kill switch [Issue #2695] opportunity and search toggle with feature flag env vars Dec 9, 2024
@doug-s-nava doug-s-nava marked this pull request as ready for review December 9, 2024 20:43
@doug-s-nava doug-s-nava force-pushed the dschrashun/2695-opportunity-kill-switch branch from db3d154 to ddddffa Compare December 10, 2024 14:10
mdragon
mdragon previously approved these changes Dec 11, 2024
Copy link
Collaborator

@mdragon mdragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

// This should be removed when the search page goes live, before May 2024
showSearchV0: true,
hideSearchV0: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could drop this at this point. Or we could try to generalize it as like searchBeta that we can keep rolling things out using and then remove the flag checks as we consider those things Released.

acouch
acouch previously approved these changes Dec 11, 2024
Copy link
Collaborator

@acouch acouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, looks great.

@doug-s-nava doug-s-nava dismissed stale reviews from acouch and mdragon via 14c5623 December 11, 2024 21:37
@doug-s-nava doug-s-nava force-pushed the dschrashun/2695-opportunity-kill-switch branch from ddddffa to 14c5623 Compare December 11, 2024 21:37
@doug-s-nava doug-s-nava force-pushed the dschrashun/2695-opportunity-kill-switch branch from 14c5623 to ce959ae Compare December 11, 2024 21:41
@doug-s-nava doug-s-nava merged commit 7a7b8a8 into main Dec 11, 2024
19 checks passed
@doug-s-nava doug-s-nava deleted the dschrashun/2695-opportunity-kill-switch branch December 11, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add kill switch for Search and Opportunity data display
3 participants