-
Notifications
You must be signed in to change notification settings - Fork 455
feat: send rich info to Plain support and track submit event for amplitude #2734
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,31 @@ | ||
| import { XIcon } from '@heroicons/react/outline'; | ||
| import { Trans } from '@lingui/macro'; | ||
| import { Box, Button, CircularProgress, SvgIcon, TextField, Typography } from '@mui/material'; | ||
| import { | ||
| Box, | ||
| Button, | ||
| Checkbox, | ||
| CircularProgress, | ||
| FormControlLabel, | ||
| SvgIcon, | ||
| TextField, | ||
| Typography, | ||
| } from '@mui/material'; | ||
| import { FormEvent, useEffect, useState } from 'react'; | ||
| import { BasicModal } from 'src/components/primitives/BasicModal'; | ||
| import { Link } from 'src/components/primitives/Link'; | ||
| import { BaseSuccessView } from 'src/components/transactions/FlowCommons/BaseSuccess'; | ||
| import { CONSENT_KEY } from 'src/store/analyticsSlice'; | ||
| import { useRootStore } from 'src/store/root'; | ||
| import { SUPPORT } from 'src/utils/events'; | ||
| import { useShallow } from 'zustand/shallow'; | ||
|
|
||
| export const SupportModal = () => { | ||
| const [feedbackDialogOpen, setFeedbackOpen] = useRootStore( | ||
| useShallow((state) => [state.feedbackDialogOpen, state.setFeedbackOpen]) | ||
| ); | ||
| const [account, trackEvent] = useRootStore( | ||
| useShallow((store) => [store.account, store.trackEvent]) | ||
| ); | ||
|
|
||
| const [value, setValue] = useState(''); | ||
| const [isLoading, setIsLoading] = useState(false); | ||
|
|
@@ -20,13 +34,19 @@ export const SupportModal = () => { | |
| const [email, setEmail] = useState(''); | ||
| const [emailError, setEmailError] = useState(''); | ||
| const [dirtyEmailField, setDirtyEmailField] = useState(false); | ||
| const [hasOptedIn, setHasOptedIn] = useState(false); | ||
| const [isShareWalletApproved, setIsShareWalletApproved] = useState(false); | ||
|
|
||
| const onBlur = () => { | ||
| if (!dirtyEmailField) setDirtyEmailField(true); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| if (feedbackDialogOpen) { | ||
| const optInStatus = | ||
| typeof window !== 'undefined' ? localStorage.getItem(CONSENT_KEY) === 'true' : false; | ||
|
|
||
|
Comment on lines
+47
to
+48
Contributor
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. may be safer to get this from root store, check analyticsSlice for some variable in there |
||
| setHasOptedIn(optInStatus); | ||
| setSuccess(false); | ||
| setError(false); | ||
| setEmailError(''); | ||
|
|
@@ -56,10 +76,10 @@ export const SupportModal = () => { | |
| setIsLoading(true); | ||
|
|
||
| const url = '/api/support-create-ticket'; | ||
|
|
||
| const payload = { | ||
| text: value, | ||
| email: email, | ||
| walletAddress: (hasOptedIn || isShareWalletApproved) && account ? account : undefined, | ||
| }; | ||
|
|
||
| try { | ||
|
|
@@ -75,15 +95,22 @@ export const SupportModal = () => { | |
| setIsLoading(false); | ||
| setValue(''); | ||
| setEmail(''); | ||
| setIsShareWalletApproved(false); | ||
| return; | ||
| } | ||
| setSuccess(true); | ||
| trackEvent(SUPPORT.TICKET_CREATED, { | ||
| type: 'Form', | ||
| hasWalletConnected: !!account, | ||
| }); | ||
| } catch (error) { | ||
| setError(true); | ||
| setIsShareWalletApproved(false); | ||
| } finally { | ||
| setIsLoading(false); | ||
| setValue(''); | ||
| setEmail(''); | ||
| setIsShareWalletApproved(false); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -92,6 +119,7 @@ export const SupportModal = () => { | |
| setEmailError(''); | ||
| setEmail(''); | ||
| setValue(''); | ||
| setIsShareWalletApproved(false); | ||
| setDirtyEmailField(false); | ||
| setSuccess(false); | ||
| setError(false); | ||
|
|
@@ -208,7 +236,7 @@ export const SupportModal = () => { | |
| sx={{ | ||
| mb: 2, | ||
| '& .MuiInputBase-input': { | ||
| padding: '6px 12px', | ||
| padding: '6px 8px', | ||
| }, | ||
| }} | ||
| /> | ||
|
|
@@ -234,6 +262,34 @@ export const SupportModal = () => { | |
| }, | ||
| }} | ||
| /> | ||
|
|
||
| {account && ( | ||
| <Box sx={{ mt: 2, p: 2, bgcolor: 'grey.50', borderRadius: 1.5 }}> | ||
| {!hasOptedIn ? ( | ||
| <FormControlLabel | ||
| control={ | ||
| <Checkbox | ||
| checked={isShareWalletApproved} | ||
| onChange={(e) => setIsShareWalletApproved(e.target.checked)} | ||
| color="primary" | ||
| size="small" | ||
| /> | ||
| } | ||
| label={ | ||
| <Box> | ||
| <Typography color="text.primary"> | ||
| <Trans> | ||
| Share my wallet address to help the support team resolve my issue | ||
| </Trans> | ||
| </Typography> | ||
| </Box> | ||
| } | ||
| /> | ||
| ) : ( | ||
| '' | ||
| )} | ||
| </Box> | ||
| )} | ||
| <Box display="flex" flexDirection={'row-reverse'} mt={3}> | ||
| <Button disabled={!value || !!emailError} variant="contained" type="submit"> | ||
| <Trans>Submit</Trans> | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,3 +143,6 @@ export const GHO_SUCCESS_MODAL = { | |
| export const SWITCH_MODAL = { | ||
| SWITCH_TYPE: 'Change switch type', | ||
| }; | ||
| export const SUPPORT = { | ||
| TICKET_CREATED: 'Support Ticket Created', // Este string es lo que ve Amplitude | ||
|
Contributor
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. spanish lol |
||
| } as const; | ||
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.
nice