Skip to content

Commit 9691178

Browse files
author
Stephen Cefali
authored
feat(onboarding): jump to setup project (#44712)
This PR adds logic to jump from the welcome screen to instrumenting the application after creating a default project based on the query params. It's a follow up to this: https://github.com/getsentry/getsentry/pull/9547
1 parent 3dfba82 commit 9691178

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

static/app/views/onboarding/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useEffect, useRef, useState} from 'react';
1+
import {useCallback, useEffect, useRef, useState} from 'react';
22
import {browserHistory, RouteComponentProps} from 'react-router';
33
import styled from '@emotion/styled';
44
import {AnimatePresence, motion, MotionProps, useAnimation} from 'framer-motion';
@@ -191,6 +191,14 @@ function Onboarding(props: Props) {
191191
);
192192
};
193193

194+
const jumpToSetupProject = useCallback(() => {
195+
const nextStep = onboardingSteps.find(({id}) => id === 'setup-docs');
196+
if (!nextStep) {
197+
return;
198+
}
199+
browserHistory.push(normalizeUrl(`/onboarding/${organization.slug}/${nextStep.id}/`));
200+
}, [onboardingSteps, organization]);
201+
194202
if (!stepObj || stepIndex === -1) {
195203
return (
196204
<Redirect
@@ -234,6 +242,7 @@ function Onboarding(props: Props) {
234242
route={props.route}
235243
router={props.router}
236244
location={props.location}
245+
jumpToSetupProject={jumpToSetupProject}
237246
{...{
238247
genSkipOnboardingLink,
239248
}}

static/app/views/onboarding/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type StepProps = Pick<
1414
> & {
1515
active: boolean;
1616
genSkipOnboardingLink: () => React.ReactNode;
17+
jumpToSetupProject: () => void;
1718
onComplete: () => void;
1819
orgId: string;
1920
organization: Organization;

static/app/views/onboarding/welcome.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ function InnerAction({title, subText, cta, src}: TextWrapperProps) {
4747
);
4848
}
4949

50-
function TargetedOnboardingWelcome({organization, ...props}: StepProps) {
50+
function TargetedOnboardingWelcome({
51+
organization,
52+
jumpToSetupProject,
53+
...props
54+
}: StepProps) {
5155
const source = 'targeted_onboarding';
5256
const [clientState, setClientState] = usePersistedOnboardingState();
5357

@@ -73,6 +77,14 @@ function TargetedOnboardingWelcome({organization, ...props}: StepProps) {
7377

7478
props.onComplete();
7579
};
80+
81+
// jump to setup project if the backend set this state for us
82+
useEffect(() => {
83+
if (clientState?.state === 'projects_selected') {
84+
jumpToSetupProject();
85+
}
86+
}, [clientState, jumpToSetupProject]);
87+
7688
return (
7789
<FallingError>
7890
{({fallingError, fallCount, isFalling}) => (

0 commit comments

Comments
 (0)