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

feat: conditional react routing #3750

Merged
merged 42 commits into from
Apr 21, 2022
Merged

Conversation

timotheeg
Copy link
Contributor

Context

We need a way to control rollout of React (and stop it if needed).

We have several constraints:

  • We should have an illegibility criteria where some form are excluded from the react rollout
  • Domain must stay constants as form.gov.sg
  • Form URLs must be constant, so whatever URLs were shared before, during, and after rollout will work without us having to maintain deprecated custom routes
  • Respondent taking SP/CP/MyInfo forms should have the same environment before and after login, so they are not confused
  • Admin can chose an environment (react/angular) and have it served consistently across multiple sessions

We considered several approach to do routing in infra, but the constraints above make it hard to do this outside application (which can have knowledge on admin/respondent and eligibility criteria based on form definitions.

Approach

  • Update old routes to have a consistent param formId in URL
  • Conditional routing is done in app code with a new controller reactMigrationController
    • new config block `reactMigration populated from new env vars
    • static assets are loaded first so the react controller can catch all urls later
  • Admins choice is saved in a cookie with 1 year expiry
    • new API endpoint /api/v3/admin/environment/(react|angular) to allow setting of the cookie (only needed if http-only)
  • Respondent choice of react/angular is saved in a session cookie. Same user may get different ui for forms during the rollout period, but a single interaction with a form, including refreshes should be consistent within one ui.

TODOs / TODISCUSS

  • Add Eligibility criteria (forms with SP/CP/MyInfo) are excluded from first phase of rollout
  • Test for all common cases (pairing session wearing hacker hats -> can we break it?)
  • Build UI in BOTH angular and React to allow switching the environment (simple api call to set cookie and redirect)
  • Discuss whether frontend needs access to the environment cookies to take decisions (cookies do not contain secure data and do not necessarily need to be http-only

Deploy Notes

New environment variables:

  • REACT_MIGRATION_RESPONDENT_ROLLOUT: number between 0 and 100
  • REACT_MIGRATION_ADMIN_ROLLOUT: number between 0 and 100

@timotheeg timotheeg changed the title Form v2/conditional routing Conditional React Routing Apr 13, 2022
@timotheeg timotheeg force-pushed the form-v2/conditional_routing branch from fbe880c to aade5b2 Compare April 13, 2022 08:29
@karrui
Copy link
Contributor

karrui commented Apr 13, 2022

I've fixed the Chromatic failure in #3751

@timotheeg timotheeg force-pushed the form-v2/conditional_routing branch from 2b2147a to fb3993a Compare April 14, 2022 02:17
@timotheeg timotheeg changed the title Conditional React Routing feat: conditional react routing Apr 14, 2022
@@ -61,6 +67,20 @@ const loggingMiddleware = () => {
if (transactionId) {
meta.transactionId = transactionId
}

// Temporary: cookies are blacklisted, but we to track the state of the rollout for this particular request
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
// Temporary: cookies are blacklisted, but we to track the state of the rollout for this particular request
// Temporary: cookies are blacklisted, but we want to track the state of the rollout for this particular request

@timotheeg timotheeg temporarily deployed to staging-al2 April 14, 2022 02:25 Inactive
@timotheeg timotheeg force-pushed the form-v2/conditional_routing branch 3 times, most recently from 0ef6314 to a0d2352 Compare April 14, 2022 02:44
@timotheeg timotheeg temporarily deployed to staging-al2 April 14, 2022 02:45 Inactive
@timotheeg timotheeg force-pushed the form-v2/conditional_routing branch from a0d2352 to a2732c0 Compare April 14, 2022 03:03
@timotheeg timotheeg temporarily deployed to staging-al2 April 14, 2022 03:03 Inactive
@timotheeg timotheeg temporarily deployed to staging-al2 April 14, 2022 03:27 Inactive
@karrui karrui temporarily deployed to staging-al2 April 14, 2022 05:23 Inactive
@timotheeg timotheeg temporarily deployed to staging-al2 April 14, 2022 07:25 Inactive
@timotheeg timotheeg temporarily deployed to staging-al2 April 14, 2022 07:42 Inactive
@timotheeg timotheeg force-pushed the form-v2/conditional_routing branch from ecdd421 to 9d3f631 Compare April 14, 2022 07:50
@timotheeg timotheeg temporarily deployed to staging-al2 April 14, 2022 07:51 Inactive
@timotheeg timotheeg force-pushed the form-v2/conditional_routing branch from 9d3f631 to fbd6d49 Compare April 19, 2022 05:25
@timotheeg timotheeg temporarily deployed to staging-al2 April 19, 2022 05:26 Inactive
@timotheeg timotheeg force-pushed the form-v2/conditional_routing branch from fbd6d49 to 07a3e72 Compare April 19, 2022 06:02
@timotheeg timotheeg temporarily deployed to staging-al2 April 19, 2022 06:03 Inactive
@timotheeg timotheeg temporarily deployed to staging-al2 April 19, 2022 08:16 Inactive
@timotheeg timotheeg force-pushed the form-v2/conditional_routing branch from 67d747e to b44dbc5 Compare April 21, 2022 07:34
@timotheeg timotheeg merged commit 25b793b into form-v2/develop Apr 21, 2022
@timotheeg timotheeg deleted the form-v2/conditional_routing branch April 21, 2022 07:39
@justynoh justynoh mentioned this pull request Oct 5, 2022
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.

2 participants