-
Notifications
You must be signed in to change notification settings - Fork 3
Redirect new users to onboarding flow #2186
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
base: main
Are you sure you want to change the base?
Redirect new users to onboarding flow #2186
Conversation
OpenAPI ChangesShow/hide 24 changes: 0 error, 0 warning, 24 info
|
OpenAPI ChangesShow/hide 24 changes: 0 error, 0 warning, 24 info
|
OpenAPI ChangesShow/hide 24 changes: 0 error, 0 warning, 24 info
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small things, but you might not need to do them if we do the following suggestion:
I noticed that when the site loads you see a flash of the content followed by the redirect over to /onboarding
. I hadn't thought of this when I wrote out the issue but I'm thinking that maybe we instead want to take care of this on the login view in the backend instead. Something along the lines of this:
class CustomLoginView(View):
"""
Redirect the user to the appropriate url after login
"""
def get(
self,
request,
*args, # noqa: ARG002
**kwargs, # noqa: ARG002
):
"""
GET endpoint for logging a user in.
"""
redirect_url = get_redirect_url(request)
if (
not request.user.profile.completed_onboarding
and not request.GET.get("skip_onboarding", "0") == "1"
):
# redirect the user to onboarding and later to the next url
params = urlencode({"next": redirect_url})
redirect_url = f"{settings.NEW_USER_REDIRECT_URL}?{params}"
return redirect(redirect_url)
This also passes along the next
parameter to the onboarding flow, I can't recall if we handle that, but we should if we don't so the user ends up where they left off.
@@ -171,7 +169,7 @@ const OnboardingPage: React.FC = () => { | |||
if (activeStep < NUM_STEPS - 1) { | |||
setActiveStep((prevActiveStep) => prevActiveStep + 1) | |||
} else { | |||
router.push(DASHBOARD_HOME) | |||
;(window as Window).location = DASHBOARD_HOME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why this change was needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea - basically there was some caching of data that happens with the profile query such that when we update the completed_onboarding it reads the cached value on the subsequent page unless we do a full reload. I spoke with @ChristopherChudzicki and it seemed like the full reload was the easiest way since we only should ever do this once per user
!user?.profile?.completed_onboarding && | ||
pathname !== urls.ONBOARDING | ||
) { | ||
if (typeof profileMutate === "function") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused why this would ever not be a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was running into some error previously but I think its removable since I moved this into useEffect. removed
OpenAPI ChangesShow/hide 24 changes: 0 error, 0 warning, 24 info
|
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/6857
Description (What does it do?)
This PR adds a "completed_onboarding" flag to the user profile that gets set to True once the user has interacted with the onboarding page after they first login.
How can this be tested?
test the "skip_onboarding" get parameter which skips the onboarding.