Skip to content

Onboarding - add nextPath logic after email verification #12342

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

Merged
merged 5 commits into from
May 28, 2025
Merged

Conversation

etiennejouan
Copy link
Contributor

@etiennejouan etiennejouan commented May 28, 2025

Context :
Plan choice on pricing page on website should redirect you the right plan on app /plan-required page (after sign in), thanks to query parameters and BillingCheckoutSessionState sync.
With email verification, an other session starts at CTA click in verification email. Initial BillingCheckoutSessionState is lost and user can't submit to the plan he choose.

Solution :
Pass a nextPath query parameter in email verification link

To test :

closes #12288

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR implements nextPath logic after email verification to maintain billing session state, ensuring users are redirected to their selected plan page after verifying their email address.

  • Added verifyEmailNextPathState to store and manage post-verification redirect paths
  • Modified usePageChangeEffectNavigateLocation to handle redirection based on verifyEmailNextPath
  • Updated SignUpInput DTO and mutation to include verifyEmailNextPath parameter
  • Added buildAppPathWithQueryParams utility but needs URI encoding for security
  • Removed isQueryParamInitializedState in favor of deep equality checks for state updates

17 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -43,6 +44,7 @@ export const usePageChangeEffectNavigateLocation = () => {
const objectMetadataItem = objectMetadataItems.find(
(objectMetadataItem) => objectMetadataItem.namePlural === objectNamePlural,
);
const verifyEmailNextPath = useRecoilValue(verifyEmailNextPathState);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider adding a type annotation for verifyEmailNextPath to make the expected type more explicit

@@ -58,6 +60,12 @@ export const usePageChangeEffectNavigateLocation = () => {
onboardingStatus === OnboardingStatus.PLAN_REQUIRED &&
!someMatchingLocationOf([AppPath.PlanRequired, AppPath.PlanRequiredSuccess])
) {
if (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not entirely satisfied of nesting verifyEmail redirection condition here (because it should not be dependant of billing), but without, chooseYouPlan modal blinks.

Copy link
Contributor

github-actions bot commented May 28, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:44573

This environment will automatically shut down when the PR is closed or after 5 hours.

@etiennejouan etiennejouan enabled auto-merge (squash) May 28, 2025 17:10
@etiennejouan etiennejouan merged commit 081376f into main May 28, 2025
52 checks passed
@etiennejouan etiennejouan deleted the ej/12289 branch May 28, 2025 17:20
jordan-chalupka pushed a commit to InsurOS/twenty that referenced this pull request Jun 1, 2025
)

Context :
Plan choice [on pricing page on website](https://twenty.com/pricing)
should redirect you the right plan on app /plan-required page (after
sign in), thanks to query parameters and BillingCheckoutSessionState
sync.
With email verification, an other session starts at CTA click in
verification email. Initial BillingCheckoutSessionState is lost and user
can't submit to the plan he choose.

Solution : 
Pass a nextPath query parameter in email verification link

To test : 
- Modify .env to add IS_BILLING_ENABLED (+ reset db + sync billing) +
IS_EMAIL_VERIFICATION_REQUIRED
- Start test from this page
http://app.localhost:3001/welcome?billingCheckoutSession={%22plan%22:%22ENTERPRISE%22,%22interval%22:%22Year%22,%22requirePaymentMethod%22:true}
- After verification, check you arrive on /plan-required page with
Enterprise plan on a yearly interval (default is Pro/monthly).

closes twentyhq#12288
jordan-chalupka pushed a commit to InsurOS/twenty that referenced this pull request Jun 1, 2025
)

Context :
Plan choice [on pricing page on website](https://twenty.com/pricing)
should redirect you the right plan on app /plan-required page (after
sign in), thanks to query parameters and BillingCheckoutSessionState
sync.
With email verification, an other session starts at CTA click in
verification email. Initial BillingCheckoutSessionState is lost and user
can't submit to the plan he choose.

Solution : 
Pass a nextPath query parameter in email verification link

To test : 
- Modify .env to add IS_BILLING_ENABLED (+ reset db + sync billing) +
IS_EMAIL_VERIFICATION_REQUIRED
- Start test from this page
http://app.localhost:3001/welcome?billingCheckoutSession={%22plan%22:%22ENTERPRISE%22,%22interval%22:%22Year%22,%22requirePaymentMethod%22:true}
- After verification, check you arrive on /plan-required page with
Enterprise plan on a yearly interval (default is Pro/monthly).

closes twentyhq#12288
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.

Plan selection is broken
2 participants