Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(onboarding): stripe return url not handled properly (#3203)

dev-rb1dfc21f1371a
diff --git a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
index d28684fe24..22ba021828 100644
--- a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
@@ -265,11 +265,11 @@ function InteractiveOnboardingInner() {
)
: undefined;
- // Detect a return-from-OAuth param synchronously so we can pre-populate
+ // Detect a return-from-external-flow param synchronously so we can pre-populate
// completed lessons before the first render, avoiding a flash of the first slide.
// Search the unfiltered LESSONS list — the returning lesson (e.g. about-us) may
// have been filtered out now that the user is authenticated.
- const returningLesson = LESSONS.find(
+ const returningLesson = LESSONS.findLast(
(l) => l.completeOnParam && params.has(l.completeOnParam)
);
const returnCompleted = returningLesson
@@ -304,8 +304,8 @@ function InteractiveOnboardingInner() {
};
// Redirect away if the backend already marks the tutorial as complete.
- // Skip the redirect when returning from OAuth — we just marked it complete
- // ourselves and still have remaining lessons to show.
+ // Skip the redirect when returning from external flow — we just marked it
+ // complete ourselves and still have remaining lessons to show.
createEffect(() => {
if (tutorialCompleted() && !returningLesson && !testMode) {
navigateAway();
@@ -426,12 +426,11 @@ function InteractiveOnboardingInner() {
shellRef.focus();
}
- // When returning from an external auth flow (e.g. Google OAuth), clean the
- // return param from the URL and run side-effects. The lessons are already
- // pre-completed synchronously via returnCompleted above.
- if (returningLesson) {
+ // When returning from an external flow, clean the return param from the URL
+ // and run side-effects. The lessons are already pre-completed synchronously.
+ if (returningLesson?.completeOnParam) {
const cleanParams = new URLSearchParams(window.location.search);
- cleanParams.delete(returningLesson.completeOnParam!);
+ cleanParams.delete(returningLesson.completeOnParam);
const qs = cleanParams.toString();
window.history.replaceState(
null,
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx
index 55d85212fb..e3bba03956 100644
--- a/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx
@@ -32,8 +32,8 @@ function ChoosePlanDemo(props: LessonContentProps) {
enabledOverride: ENABLE_INVITE_TEAM_ONBOARDING_OVERRIDE,
});
- // Returns to /welcome?subscriptionSuccess=true on success, which triggers
- // completeOnParam and lands the user on the next lesson (team-choice or launch).
+ // Returns to /welcome?subscriptionSuccess=true on success, which completes
+ // all lessons except launch, landing the user on the launch lesson.
const checkoutMutation = useOnboardingCheckoutMutation({
onSuccess: (result) => {
analytics.track('subscription_start', {
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/invite-team.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/invite-team.tsx
index ceda0f7f23..78eb8184ba 100644
--- a/js/app/packages/app/component/interactive-onboarding/lessons/invite-team.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/lessons/invite-team.tsx
@@ -406,6 +406,7 @@ export const inviteTeamLesson: LessonDefinition = {
content: InviteTeamContent,
demo: InviteTeamDemo,
order: 90,
+ completeOnParam: 'subscriptionSuccess',
previousLesson: 'team-choice',
onBack: ({ onboarding }) => {
onboarding.setTeamName('');
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/review-pay.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/review-pay.tsx
index a1d4c35ac2..b5a6bab218 100644
--- a/js/app/packages/app/component/interactive-onboarding/lessons/review-pay.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/lessons/review-pay.tsx
@@ -50,8 +50,8 @@ function ReviewPayDemo(props: LessonContentProps) {
const isAuthenticated = useIsAuthenticated();
const [isRedirecting, setIsRedirecting] = createSignal(false);
- // Returns to /welcome?subscriptionSuccess=true on success, which triggers
- // completeOnParam and runs onCompleteParam to create the pending team.
+ // Returns to /welcome?subscriptionSuccess=true on success, which completes
+ // all lessons except launch and runs onCompleteParam to create the pending team.
const checkoutMutation = useOnboardingCheckoutMutation({
onSuccess: (result) => {
analytics.track('subscription_start', {
@@ -362,6 +362,7 @@ async function createPendingTeamOnReturn(): Promise<boolean> {
}
await invalidateUserTeams();
+
clearPendingTeam();
analytics.track('onboarding_team_created', {
@@ -384,6 +385,8 @@ export const reviewPayLesson: LessonDefinition = {
demo: ReviewPayDemo,
order: 95,
hideContinue: true,
+ completeOnParam: 'subscriptionSuccess',
+ onCompleteParam: createPendingTeamOnReturn,
previousLesson: ({ onboarding, isLessonSkipped }) => {
// When teams feature is disabled, these lessons are skipped
if (isLessonSkipped('team-choice')) {
@@ -394,6 +397,4 @@ export const reviewPayLesson: LessonDefinition = {
onboarding.teamName().trim() !== '';
return hasTeam ? 'invite-team' : 'team-choice';
},
- completeOnParam: 'subscriptionSuccess',
- onCompleteParam: createPendingTeamOnReturn,
};
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/team-choice.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/team-choice.tsx
index a9dd1194fb..3e2ad729b2 100644
--- a/js/app/packages/app/component/interactive-onboarding/lessons/team-choice.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/lessons/team-choice.tsx
@@ -25,8 +25,8 @@ function TeamChoiceDemo(props: LessonContentProps) {
const isAuthenticated = useIsAuthenticated();
const [isRedirecting, setIsRedirecting] = createSignal(false);
- // Returns to /welcome?subscriptionSuccess=true on success, which triggers
- // completeOnParam on choose-plan and lands the user on launch.
+ // Returns to /welcome?subscriptionSuccess=true on success, which completes
+ // all lessons except launch, landing the user on the launch lesson.
const checkoutMutation = useOnboardingCheckoutMutation({
onSuccess: (result) => {
analytics.track('subscription_start', {
@@ -68,9 +68,7 @@ function TeamChoiceDemo(props: LessonContentProps) {
onboarding.setInvitedMembers([]);
onboarding.setTeamName('');
- checkoutMutation.mutate({
- tier: tier as PaidPlanTier,
- });
+ checkoutMutation.mutate({ tier: tier as PaidPlanTier });
};
return (
@@ -128,6 +126,7 @@ export const teamChoiceLesson: LessonDefinition = {
demo: TeamChoiceDemo,
order: 89,
hideContinue: true,
+ completeOnParam: 'subscriptionSuccess',
previousLesson: ({ isLessonSkipped, hasPaidAccess }) => {
if (isLessonSkipped('choose-plan') || hasPaidAccess) {
return undefined;