-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat: add modal on get started page for onboarding experiment v2 #5401
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0da951b
feat: add modal on get started page for onboarding experiment v2
jainpawan21 73740fc
fix: add segment event for modal open
jainpawan21 5bb7125
fix: cspell check error
jainpawan21 52cf53c
feat: change button text
jainpawan21 e4172c7
fix: spell check error
jainpawan21 d1c7fc8
fix: add const for local storage key
jainpawan21 d0de31e
fix: remove prod only condition
jainpawan21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const OnboardingExperimentV2ModalKey = 'nv_onboarding_modal'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
apps/web/src/pages/quick-start/components/OnboardingExperimentModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { useState } from 'react'; | ||
import { Modal, useMantineTheme, Grid } from '@mantine/core'; | ||
|
||
import styled from '@emotion/styled'; | ||
import { colors, shadows, Title, Button } from '@novu/design-system'; | ||
import { useAuthContext, useSegment } from '@novu/shared-web'; | ||
import { useCreateOnboardingExperimentWorkflow } from '../../../api/hooks/notification-templates/useCreateOnboardingExperimentWorkflow'; | ||
import { OnboardingExperimentV2ModalKey } from '../../../constants/experimentsConstants'; | ||
import { OnBoardingAnalyticsEnum } from '../consts'; | ||
|
||
export function OnboardingExperimentModal() { | ||
const [opened, setOpened] = useState(true); | ||
const theme = useMantineTheme(); | ||
const segment = useSegment(); | ||
const { currentOrganization } = useAuthContext(); | ||
const { | ||
createOnboardingExperimentWorkflow, | ||
isLoading: IsCreateOnboardingExpWorkflowLoading, | ||
isDisabled: isIsCreateOnboardingExpWorkflowDisabled, | ||
} = useCreateOnboardingExperimentWorkflow(); | ||
const handleOnClose = () => { | ||
setOpened(true); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
opened={opened} | ||
overlayColor={theme.colorScheme === 'dark' ? colors.BGDark : colors.BGLight} | ||
overlayOpacity={0.7} | ||
styles={{ | ||
modal: { | ||
backgroundColor: theme.colorScheme === 'dark' ? colors.B15 : colors.white, | ||
width: '700px', | ||
}, | ||
body: { | ||
paddingTop: '5px', | ||
paddingInline: '8px', | ||
}, | ||
}} | ||
title={<Title size={2}>What would you like to do first?</Title>} | ||
sx={{ backdropFilter: 'blur(10px)' }} | ||
shadow={theme.colorScheme === 'dark' ? shadows.dark : shadows.medium} | ||
radius="md" | ||
size="lg" | ||
onClose={handleOnClose} | ||
centered | ||
withCloseButton={false} | ||
> | ||
<Grid> | ||
<Grid.Col xs={12} md={6} mb={20}> | ||
<ChannelCard> | ||
<TitleRow> Send test notification</TitleRow> | ||
<Description>Learn how to setup a workflow and send your first email notification.</Description> | ||
<StyledButton | ||
loading={IsCreateOnboardingExpWorkflowLoading} | ||
disabled={isIsCreateOnboardingExpWorkflowDisabled} | ||
pulse={true} | ||
variant="gradient" | ||
onClick={async () => { | ||
segment.track(OnBoardingAnalyticsEnum.ONBOARDING_EXPERIMENT_TEST_NOTIFICATION, { | ||
action: 'Modal - Send test notification', | ||
experiment_id: '2024-w15-onb', | ||
_organization: currentOrganization?._id, | ||
}); | ||
localStorage.removeItem(OnboardingExperimentV2ModalKey); | ||
createOnboardingExperimentWorkflow(); | ||
}} | ||
> | ||
Send test notification now | ||
</StyledButton> | ||
</ChannelCard> | ||
</Grid.Col> | ||
<Grid.Col xs={12} md={6} mb={20}> | ||
<ChannelCard> | ||
<TitleRow> Look around</TitleRow> | ||
<Description>Start exploring the Novu app on your own terms</Description> | ||
<StyledButton | ||
variant="outline" | ||
onClick={async () => { | ||
segment.track(OnBoardingAnalyticsEnum.ONBOARDING_EXPERIMENT_TEST_NOTIFICATION, { | ||
action: 'Modal - Get started', | ||
experiment_id: '2024-w15-onb', | ||
_organization: currentOrganization?._id, | ||
}); | ||
localStorage.removeItem(OnboardingExperimentV2ModalKey); | ||
setOpened(false); | ||
}} | ||
> | ||
Get started | ||
</StyledButton> | ||
</ChannelCard> | ||
</Grid.Col> | ||
</Grid> | ||
</Modal> | ||
); | ||
} | ||
|
||
const ChannelCard = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
flex-direction: column; | ||
max-width: 230px; | ||
`; | ||
|
||
const TitleRow = styled.div` | ||
display: flex; | ||
align-items: center; | ||
font-size: 20px; | ||
line-height: 32px; | ||
margin-bottom: 8px; | ||
`; | ||
|
||
const Description = styled.div` | ||
flex: auto; | ||
font-size: 16px; | ||
line-height: 20px; | ||
margin-bottom: 20px; | ||
color: ${colors.B60}; | ||
height: 60px; | ||
`; | ||
|
||
const StyledButton = styled(Button)` | ||
width: fit-content; | ||
outline: none; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,8 +66,7 @@ novu.trigger('${identifier}', ${JSON.stringify( | |
2 | ||
) | ||
.replace(/"([^"]+)":/g, '$1:') | ||
.replace(/"/g, "'") | ||
.replaceAll('\n', '\n ')}); | ||
.replace(/"/g, "'")}); | ||
`; | ||
|
||
return ( | ||
|
@@ -85,19 +84,19 @@ export const getCurlTriggerSnippet = ( | |
snippet?: Record<string, unknown> | ||
) => { | ||
const curlSnippet = `curl --location --request POST '${API_ROOT}/v1/events/trigger' \\ | ||
--header 'Authorization: ApiKey <REPLACE_WITH_API_KEY>' \\ | ||
--header 'Content-Type: application/json' \\ | ||
--data-raw '${JSON.stringify( | ||
{ | ||
name: identifier, | ||
to, | ||
payload, | ||
overrides, | ||
...snippet, | ||
}, | ||
null, | ||
2 | ||
).replaceAll('\n', '\n ')}' | ||
--header 'Authorization: ApiKey <REPLACE_WITH_API_KEY>' \\ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed code indentation for both nodejs and curl Before 👇🏻 Screen.Recording.2024-04-12.at.5.10.02.PM.movAfter 👇🏻 Screen.Recording.2024-04-12.at.5.09.42.PM.mov |
||
--header 'Content-Type: application/json' \\ | ||
--data-raw '${JSON.stringify( | ||
{ | ||
name: identifier, | ||
to, | ||
payload, | ||
overrides, | ||
...snippet, | ||
}, | ||
null, | ||
2 | ||
)}' | ||
`; | ||
|
||
return ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The modal component is initialized with the
opened
state set totrue
and never set tofalse
inhandleOnClose
. This might prevent the modal from closing as expected. Consider settingopened
tofalse
in thehandleOnClose
function.Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setOpened(false)
inhandleOnClose
will allow the user to close modal by clicking outside the modal. As per experiment requirement, modal should be closed only when anyof the buttons are clickedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jainpawan21, thank you for clarifying the intended behavior of the modal. It makes sense to restrict the modal closure to button clicks only, in line with the experiment's requirements. If there's anything else that needs to be adjusted or if you have further instructions, please let me know!
New Learnings Added