Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
We need to know based on the URL what step we are on, and go to the correct step given a single URL. This needs to work for "named" steps, but also unnamed steps for making the process of creating onboarding flows easier.
Changes
I found creating this logic complicated. Each step that the onboarding natively supports (sdks, billing, intro) has a key, eg
?step=billing
. This needs to be dynamic because the billing step won't always be there, and it won't always be in the same order. So we have all the steps stored and find the component with the correct component name for the key.If something is just an
<OnboardingStep>
then it won't have a special name, so we set the step key as the step number.This works in both directions - navigating to a URL with a specific step and also using the app to go to the next step, the URL will update.
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
How did you test this code?
No tests yet...