1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-12 13:48:35 +02:00

feat: improve onboarding flow (#8327)

1. Refetch features when creating the flag. It took a while for it to
appear before.
2. Fix NodeJS snippet and make texts more clear.
This commit is contained in:
Jaanus Sellin 2024-10-02 10:39:47 +03:00 committed by GitHub
parent 6936da7403
commit e51e6cc507
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 14 deletions

View File

@ -45,9 +45,10 @@ export const SdkConnected: FC<ISdkConnectedProps> = ({ sdk }) => {
<Box sx={{ mt: 2 }}> <Box sx={{ mt: 2 }}>
<SectionHeader>Production settings</SectionHeader> <SectionHeader>Production settings</SectionHeader>
<Typography variant='body2'> <Typography variant='body2'>
In order to validate the connection, we changed some You have successfully connected your SDK. In the
settings that you might want to revert. We recommend the previous code example, the settings were optimized for
following default settings. development. We recommend the following setup for
production.
</Typography> </Typography>
<Markdown components={{ code: CodeRenderer }}> <Markdown components={{ code: CodeRenderer }}>
{productionSnippet} {productionSnippet}

View File

@ -20,10 +20,6 @@ setInterval(() => {
``` ```
--- ---
### Production settings
In order to validate the connection, we changed some settings that you might want to revert. We recommend the following default settings.
```js ```js
const { initialize } = require('unleash-client'); const { initialize } = require('unleash-client');
@ -35,10 +31,6 @@ const unleash = initialize({
``` ```
--- ---
### Additional resources
Now that weve validated the connection, you might want to look into more advanced use cases and examples:
- [SDK repository with documentation](https://github.com/Unleash/unleash-client-node) - [SDK repository with documentation](https://github.com/Unleash/unleash-client-node)
- [Node.js SDK example with CodeSandbox](https://github.com/Unleash/unleash-sdk-examples/tree/main/NodeJS) - [Node.js SDK example with CodeSandbox](https://github.com/Unleash/unleash-sdk-examples/tree/main/NodeJS)
- [Node.js SDK tutorial](https://dev.to/reeshee/how-to-implement-feature-flags-in-nodejs-using-unleash-3907) - [Node.js SDK tutorial](https://dev.to/reeshee/how-to-implement-feature-flags-in-nodejs-using-unleash-3907)

View File

@ -22,6 +22,7 @@ test('Project can start onboarding', async () => {
projectId={projectId} projectId={projectId}
setConnectSdkOpen={() => {}} setConnectSdkOpen={() => {}}
setOnboardingFlow={() => {}} setOnboardingFlow={() => {}}
refetchFeatures={() => {}}
/> />
} }
/> />
@ -50,6 +51,7 @@ test('Project can connect SDK', async () => {
projectId={projectId} projectId={projectId}
setConnectSdkOpen={() => {}} setConnectSdkOpen={() => {}}
setOnboardingFlow={() => {}} setOnboardingFlow={() => {}}
refetchFeatures={() => {}}
/> />
} }
/> />

View File

@ -14,10 +14,12 @@ interface IProjectOnboardingProps {
projectId: string; projectId: string;
setConnectSdkOpen: (open: boolean) => void; setConnectSdkOpen: (open: boolean) => void;
setOnboardingFlow: (status: 'visible' | 'closed') => void; setOnboardingFlow: (status: 'visible' | 'closed') => void;
refetchFeatures: () => void;
} }
interface ICreateFlagProps { interface ICreateFlagProps {
projectId: string; projectId: string;
refetchFeatures: () => void;
} }
const Container = styled('div')(({ theme }) => ({ const Container = styled('div')(({ theme }) => ({
@ -101,6 +103,7 @@ export const ProjectOnboarding = ({
projectId, projectId,
setConnectSdkOpen, setConnectSdkOpen,
setOnboardingFlow, setOnboardingFlow,
refetchFeatures,
}: IProjectOnboardingProps) => { }: IProjectOnboardingProps) => {
const { project } = useProjectOverview(projectId); const { project } = useProjectOverview(projectId);
const isFirstFlagCreated = const isFirstFlagCreated =
@ -133,7 +136,10 @@ export const ProjectOnboarding = ({
'first-flag-created' ? ( 'first-flag-created' ? (
<ExistingFlag /> <ExistingFlag />
) : ( ) : (
<CreateFlag projectId={projectId} /> <CreateFlag
projectId={projectId}
refetchFeatures={refetchFeatures}
/>
)} )}
</ActionBox> </ActionBox>
<ActionBox> <ActionBox>
@ -166,7 +172,7 @@ export const ProjectOnboarding = ({
); );
}; };
const CreateFlag = ({ projectId }: ICreateFlagProps) => { const CreateFlag = ({ projectId, refetchFeatures }: ICreateFlagProps) => {
const { refetch } = useProjectOverview(projectId); const { refetch } = useProjectOverview(projectId);
return ( return (
<> <>
@ -181,7 +187,10 @@ const CreateFlag = ({ projectId }: ICreateFlagProps) => {
<FlagCreationButton <FlagCreationButton
text='Create flag' text='Create flag'
skipNavigationOnComplete={true} skipNavigationOnComplete={true}
onSuccess={refetch} onSuccess={() => {
refetch();
refetchFeatures();
}}
/> />
</> </>
); );

View File

@ -426,6 +426,7 @@ export const ProjectFeatureToggles = ({
projectId={projectId} projectId={projectId}
setConnectSdkOpen={setConnectSdkOpen} setConnectSdkOpen={setConnectSdkOpen}
setOnboardingFlow={setOnboardingFlow} setOnboardingFlow={setOnboardingFlow}
refetchFeatures={refetch}
/> />
} }
/> />