Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
8ef67799
Commit
8ef67799
authored
Sep 20, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mixpanel events
parent
d75b4b4e
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
153 additions
and
28 deletions
+153
-28
utils.ts
lib/mixpanel/utils.ts
+26
-4
MyProfile.tsx
ui/pages/MyProfile.tsx
+13
-2
AuthModal.tsx
ui/snippets/auth/AuthModal.tsx
+58
-4
AuthModalScreenConnectWallet.tsx
ui/snippets/auth/screens/AuthModalScreenConnectWallet.tsx
+5
-2
AuthModalScreenEmail.tsx
ui/snippets/auth/screens/AuthModalScreenEmail.tsx
+20
-2
AuthModalScreenSelectMethod.tsx
ui/snippets/auth/screens/AuthModalScreenSelectMethod.tsx
+10
-0
useLogout.ts
ui/snippets/auth/useLogout.ts
+3
-0
useSignInWithWallet.ts
ui/snippets/auth/useSignInWithWallet.ts
+7
-3
UserProfileButton.tsx
ui/snippets/user/profile/UserProfileButton.tsx
+6
-10
UserProfileContentWallet.tsx
ui/snippets/user/profile/UserProfileContentWallet.tsx
+1
-1
UserProfileDesktop.tsx
ui/snippets/user/profile/UserProfileDesktop.tsx
+2
-0
UserProfileMobile.tsx
ui/snippets/user/profile/UserProfileMobile.tsx
+2
-0
No files found.
lib/mixpanel/utils.ts
View file @
8ef67799
...
@@ -6,11 +6,13 @@ export enum EventTypes {
...
@@ -6,11 +6,13 @@ export enum EventTypes {
SEARCH_QUERY
=
'
Search query
'
,
SEARCH_QUERY
=
'
Search query
'
,
LOCAL_SEARCH
=
'
Local search
'
,
LOCAL_SEARCH
=
'
Local search
'
,
ADD_TO_WALLET
=
'
Add to wallet
'
,
ADD_TO_WALLET
=
'
Add to wallet
'
,
ACCOUNT_ACCESS
=
'
Account access
'
,
// deprecated
ACCOUNT_ACCESS
=
'
Account access
'
,
LOGIN
=
'
Login
'
,
ACCOUNT_LINK_INFO
=
'
Account link info
'
,
PRIVATE_TAG
=
'
Private tag
'
,
PRIVATE_TAG
=
'
Private tag
'
,
VERIFY_ADDRESS
=
'
Verify address
'
,
VERIFY_ADDRESS
=
'
Verify address
'
,
VERIFY_TOKEN
=
'
Verify token
'
,
VERIFY_TOKEN
=
'
Verify token
'
,
WALLET_CONNECT
=
'
Wallet connect
'
,
// 🦆
WALLET_CONNECT
=
'
Wallet connect
'
,
WALLET_ACTION
=
'
Wallet action
'
,
WALLET_ACTION
=
'
Wallet action
'
,
CONTRACT_INTERACTION
=
'
Contract interaction
'
,
CONTRACT_INTERACTION
=
'
Contract interaction
'
,
CONTRACT_VERIFICATION
=
'
Contract verification
'
,
CONTRACT_VERIFICATION
=
'
Contract verification
'
,
...
@@ -54,7 +56,27 @@ Type extends EventTypes.ADD_TO_WALLET ? (
...
@@ -54,7 +56,27 @@ Type extends EventTypes.ADD_TO_WALLET ? (
}
}
)
:
)
:
Type
extends
EventTypes
.
ACCOUNT_ACCESS
?
{
Type
extends
EventTypes
.
ACCOUNT_ACCESS
?
{
'
Action
'
:
'
Logged out
'
;
'
Action
'
:
'
Dropdown open
'
|
'
Logged out
'
;
}
:
Type
extends
EventTypes
.
LOGIN
?
(
{
'
Action
'
:
'
Started
'
;
'
Source
'
:
string
;
}
|
{
'
Action
'
:
'
Wallet
'
|
'
Email
'
;
'
Source
'
:
'
Options selector
'
;
}
|
{
'
Action
'
:
'
OTP sent
'
;
'
Source
'
:
'
Email
'
;
}
|
{
'
Action
'
:
'
Success
'
;
'
Source
'
:
'
Email
'
|
'
Wallet
'
;
}
)
:
Type
extends
EventTypes
.
ACCOUNT_LINK_INFO
?
{
'
Source
'
:
'
Profile
'
|
'
Login modal
'
|
'
Profile dropdown
'
;
'
Status
'
:
'
Started
'
|
'
OTP sent
'
|
'
Finished
'
;
'
Type
'
:
'
Email
'
|
'
Wallet
'
;
}
:
}
:
Type
extends
EventTypes
.
PRIVATE_TAG
?
{
Type
extends
EventTypes
.
PRIVATE_TAG
?
{
'
Action
'
:
'
Form opened
'
|
'
Submit
'
;
'
Action
'
:
'
Form opened
'
|
'
Submit
'
;
...
@@ -75,7 +97,7 @@ Type extends EventTypes.VERIFY_TOKEN ? {
...
@@ -75,7 +97,7 @@ Type extends EventTypes.VERIFY_TOKEN ? {
'
Action
'
:
'
Form opened
'
|
'
Submit
'
;
'
Action
'
:
'
Form opened
'
|
'
Submit
'
;
}
:
}
:
Type
extends
EventTypes
.
WALLET_CONNECT
?
{
Type
extends
EventTypes
.
WALLET_CONNECT
?
{
'
Source
'
:
'
Header
'
|
'
Smart contracts
'
|
'
Swap button
'
;
'
Source
'
:
'
Header
'
|
'
Login
'
|
'
Profile
'
|
'
Profile dropdown
'
|
'
Smart contracts
'
|
'
Swap button
'
;
'
Status
'
:
'
Started
'
|
'
Connected
'
;
'
Status
'
:
'
Started
'
|
'
Connected
'
;
}
:
}
:
Type
extends
EventTypes
.
WALLET_ACTION
?
(
Type
extends
EventTypes
.
WALLET_ACTION
?
(
...
...
ui/pages/MyProfile.tsx
View file @
8ef67799
...
@@ -13,6 +13,15 @@ import AuthModal from 'ui/snippets/auth/AuthModal';
...
@@ -13,6 +13,15 @@ import AuthModal from 'ui/snippets/auth/AuthModal';
import
useProfileQuery
from
'
ui/snippets/auth/useProfileQuery
'
;
import
useProfileQuery
from
'
ui/snippets/auth/useProfileQuery
'
;
import
useRedirectForInvalidAuthToken
from
'
ui/snippets/auth/useRedirectForInvalidAuthToken
'
;
import
useRedirectForInvalidAuthToken
from
'
ui/snippets/auth/useRedirectForInvalidAuthToken
'
;
const
MIXPANEL_CONFIG
=
{
wallet_connect
:
{
source
:
'
Profile
'
as
const
,
},
account_link_info
:
{
source
:
'
Profile
'
as
const
,
},
};
const
MyProfile
=
()
=>
{
const
MyProfile
=
()
=>
{
const
[
authInitialScreen
,
setAuthInitialScreen
]
=
React
.
useState
<
Screen
>
();
const
[
authInitialScreen
,
setAuthInitialScreen
]
=
React
.
useState
<
Screen
>
();
const
authModal
=
useDisclosure
();
const
authModal
=
useDisclosure
();
...
@@ -38,9 +47,11 @@ const MyProfile = () => {
...
@@ -38,9 +47,11 @@ const MyProfile = () => {
<>
<>
<
Flex
maxW=
"480px"
mt=
{
8
}
flexDir=
"column"
rowGap=
{
12
}
>
<
Flex
maxW=
"480px"
mt=
{
8
}
flexDir=
"column"
rowGap=
{
12
}
>
<
MyProfileEmail
profileQuery=
{
profileQuery
}
/>
<
MyProfileEmail
profileQuery=
{
profileQuery
}
/>
{
config
.
features
.
blockchainInteraction
.
isEnabled
&&
<
MyProfileWallet
profileQuery=
{
profileQuery
}
onAddWallet=
{
handleAddWalletClick
}
/>
}
{
config
.
features
.
blockchainInteraction
.
isEnabled
&&
<
MyProfileWallet
profileQuery=
{
profileQuery
}
onAddWallet=
{
handleAddWalletClick
}
/>
}
</
Flex
>
</
Flex
>
{
authModal
.
isOpen
&&
authInitialScreen
&&
<
AuthModal
initialScreen=
{
authInitialScreen
}
onClose=
{
authModal
.
onClose
}
/>
}
{
authModal
.
isOpen
&&
authInitialScreen
&&
<
AuthModal
initialScreen=
{
authInitialScreen
}
onClose=
{
authModal
.
onClose
}
mixpanelConfig=
{
MIXPANEL_CONFIG
}
/>
}
</>
</>
);
);
})();
})();
...
...
ui/snippets/auth/AuthModal.tsx
View file @
8ef67799
import
{
Modal
,
ModalBody
,
ModalCloseButton
,
ModalContent
,
ModalHeader
,
ModalOverlay
}
from
'
@chakra-ui/react
'
;
import
{
Modal
,
ModalBody
,
ModalCloseButton
,
ModalContent
,
ModalHeader
,
ModalOverlay
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
Screen
,
ScreenSuccess
}
from
'
./types
'
;
import
type
{
Screen
,
ScreenSuccess
}
from
'
./types
'
;
import
*
as
mixpanel
from
'
lib/mixpanel
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
AuthModalScreenConnectWallet
from
'
./screens/AuthModalScreenConnectWallet
'
;
import
AuthModalScreenConnectWallet
from
'
./screens/AuthModalScreenConnectWallet
'
;
...
@@ -16,13 +18,38 @@ import useProfileQuery from './useProfileQuery';
...
@@ -16,13 +18,38 @@ import useProfileQuery from './useProfileQuery';
interface
Props
{
interface
Props
{
initialScreen
:
Screen
;
initialScreen
:
Screen
;
onClose
:
(
isSuccess
?:
boolean
)
=>
void
;
onClose
:
(
isSuccess
?:
boolean
)
=>
void
;
mixpanelConfig
?:
{
'
wallet_connect
'
:
{
source
:
mixpanel
.
EventPayload
<
mixpanel
.
EventTypes
.
WALLET_CONNECT
>
[
'
Source
'
];
};
'
account_link_info
'
:
{
source
:
mixpanel
.
EventPayload
<
mixpanel
.
EventTypes
.
ACCOUNT_LINK_INFO
>
[
'
Source
'
];
};
};
}
}
const
AuthModal
=
({
initialScreen
,
onClose
}:
Props
)
=>
{
const
AuthModal
=
({
initialScreen
,
onClose
,
mixpanelConfig
}:
Props
)
=>
{
const
[
steps
,
setSteps
]
=
React
.
useState
<
Array
<
Screen
>>
([
initialScreen
]);
const
[
steps
,
setSteps
]
=
React
.
useState
<
Array
<
Screen
>>
([
initialScreen
]);
const
[
isSuccess
,
setIsSuccess
]
=
React
.
useState
(
false
);
const
[
isSuccess
,
setIsSuccess
]
=
React
.
useState
(
false
);
const
router
=
useRouter
();
const
profileQuery
=
useProfileQuery
();
const
profileQuery
=
useProfileQuery
();
React
.
useEffect
(()
=>
{
if
(
'
isAuth
'
in
initialScreen
&&
initialScreen
.
isAuth
)
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
ACCOUNT_LINK_INFO
,
{
Status
:
'
Started
'
,
Type
:
initialScreen
.
type
===
'
connect_wallet
'
?
'
Wallet
'
:
'
Email
'
,
Source
:
mixpanelConfig
?.
account_link_info
.
source
??
'
Profile dropdown
'
,
});
}
else
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
LOGIN
,
{
Action
:
'
Started
'
,
Source
:
mixpanel
.
getPageType
(
router
.
pathname
),
});
}
},
[
initialScreen
,
mixpanelConfig
,
router
.
pathname
]);
const
onNextStep
=
React
.
useCallback
((
screen
:
Screen
)
=>
{
const
onNextStep
=
React
.
useCallback
((
screen
:
Screen
)
=>
{
setSteps
((
prev
)
=>
[
...
prev
,
screen
]);
setSteps
((
prev
)
=>
[
...
prev
,
screen
]);
},
[]);
},
[]);
...
@@ -37,12 +64,26 @@ const AuthModal = ({ initialScreen, onClose }: Props) => {
...
@@ -37,12 +64,26 @@ const AuthModal = ({ initialScreen, onClose }: Props) => {
const
onAuthSuccess
=
React
.
useCallback
(
async
(
screen
:
ScreenSuccess
)
=>
{
const
onAuthSuccess
=
React
.
useCallback
(
async
(
screen
:
ScreenSuccess
)
=>
{
setIsSuccess
(
true
);
setIsSuccess
(
true
);
if
(
'
isAuth
'
in
initialScreen
&&
initialScreen
.
isAuth
)
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
ACCOUNT_LINK_INFO
,
{
Status
:
'
Finished
'
,
Type
:
screen
.
type
===
'
success_wallet
'
?
'
Wallet
'
:
'
Email
'
,
Source
:
mixpanelConfig
?.
account_link_info
.
source
??
'
Profile dropdown
'
,
});
}
else
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
LOGIN
,
{
Action
:
'
Success
'
,
Source
:
screen
.
type
===
'
success_wallet
'
?
'
Wallet
'
:
'
Email
'
,
});
}
const
{
data
}
=
await
profileQuery
.
refetch
();
const
{
data
}
=
await
profileQuery
.
refetch
();
if
(
data
)
{
if
(
data
)
{
onNextStep
({
...
screen
,
profile
:
data
});
onNextStep
({
...
screen
,
profile
:
data
});
}
}
// TODO @tom2drum handle error case
// TODO @tom2drum handle error case
},
[
onNextStep
,
profileQuery
]);
},
[
initialScreen
,
mixpanelConfig
?.
account_link_info
.
source
,
onNextStep
,
profileQuery
]);
const
onModalClose
=
React
.
useCallback
(()
=>
{
const
onModalClose
=
React
.
useCallback
(()
=>
{
onClose
(
isSuccess
);
onClose
(
isSuccess
);
...
@@ -71,9 +112,22 @@ const AuthModal = ({ initialScreen, onClose }: Props) => {
...
@@ -71,9 +112,22 @@ const AuthModal = ({ initialScreen, onClose }: Props) => {
case
'
select_method
'
:
case
'
select_method
'
:
return
<
AuthModalScreenSelectMethod
onSelectMethod=
{
onNextStep
}
/>;
return
<
AuthModalScreenSelectMethod
onSelectMethod=
{
onNextStep
}
/>;
case
'
connect_wallet
'
:
case
'
connect_wallet
'
:
return
<
AuthModalScreenConnectWallet
onSuccess=
{
onAuthSuccess
}
onError=
{
onReset
}
isAuth=
{
currentStep
.
isAuth
}
/>;
return
(
<
AuthModalScreenConnectWallet
onSuccess=
{
onAuthSuccess
}
onError=
{
onReset
}
isAuth=
{
currentStep
.
isAuth
}
source=
{
mixpanelConfig
?.
wallet_connect
.
source
}
/>
);
case
'
email
'
:
case
'
email
'
:
return
<
AuthModalScreenEmail
onSubmit=
{
onNextStep
}
isAuth=
{
currentStep
.
isAuth
}
/>;
return
(
<
AuthModalScreenEmail
onSubmit=
{
onNextStep
}
isAuth=
{
currentStep
.
isAuth
}
mixpanelConfig=
{
mixpanelConfig
}
/>
);
case
'
otp_code
'
:
case
'
otp_code
'
:
return
<
AuthModalScreenOtpCode
email=
{
currentStep
.
email
}
onSuccess=
{
onAuthSuccess
}
isAuth=
{
currentStep
.
isAuth
}
/>;
return
<
AuthModalScreenOtpCode
email=
{
currentStep
.
email
}
onSuccess=
{
onAuthSuccess
}
isAuth=
{
currentStep
.
isAuth
}
/>;
case
'
success_email
'
:
case
'
success_email
'
:
...
...
ui/snippets/auth/screens/AuthModalScreenConnectWallet.tsx
View file @
8ef67799
...
@@ -3,15 +3,18 @@ import React from 'react';
...
@@ -3,15 +3,18 @@ import React from 'react';
import
type
{
ScreenSuccess
}
from
'
../types
'
;
import
type
{
ScreenSuccess
}
from
'
../types
'
;
import
type
*
as
mixpanel
from
'
lib/mixpanel
'
;
import
useSignInWithWallet
from
'
../useSignInWithWallet
'
;
import
useSignInWithWallet
from
'
../useSignInWithWallet
'
;
interface
Props
{
interface
Props
{
onSuccess
:
(
screen
:
ScreenSuccess
)
=>
void
;
onSuccess
:
(
screen
:
ScreenSuccess
)
=>
void
;
onError
:
(
isAuth
?:
boolean
)
=>
void
;
onError
:
(
isAuth
?:
boolean
)
=>
void
;
isAuth
?:
boolean
;
isAuth
?:
boolean
;
source
?:
mixpanel
.
EventPayload
<
mixpanel
.
EventTypes
.
WALLET_CONNECT
>
[
'
Source
'
];
}
}
const
AuthModalScreenConnectWallet
=
({
onSuccess
,
onError
,
isAuth
}:
Props
)
=>
{
const
AuthModalScreenConnectWallet
=
({
onSuccess
,
onError
,
isAuth
,
source
}:
Props
)
=>
{
const
isStartedRef
=
React
.
useRef
(
false
);
const
isStartedRef
=
React
.
useRef
(
false
);
const
handleSignInSuccess
=
React
.
useCallback
(({
address
}:
{
address
:
string
})
=>
{
const
handleSignInSuccess
=
React
.
useCallback
(({
address
}:
{
address
:
string
})
=>
{
...
@@ -22,7 +25,7 @@ const AuthModalScreenConnectWallet = ({ onSuccess, onError, isAuth }: Props) =>
...
@@ -22,7 +25,7 @@ const AuthModalScreenConnectWallet = ({ onSuccess, onError, isAuth }: Props) =>
onError
(
isAuth
);
onError
(
isAuth
);
},
[
onError
,
isAuth
]);
},
[
onError
,
isAuth
]);
const
{
start
}
=
useSignInWithWallet
({
onSuccess
:
handleSignInSuccess
,
onError
:
handleSignInError
});
const
{
start
}
=
useSignInWithWallet
({
onSuccess
:
handleSignInSuccess
,
onError
:
handleSignInError
,
source
});
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
!
isStartedRef
.
current
)
{
if
(
!
isStartedRef
.
current
)
{
...
...
ui/snippets/auth/screens/AuthModalScreenEmail.tsx
View file @
8ef67799
...
@@ -8,6 +8,7 @@ import type { EmailFormFields, Screen } from '../types';
...
@@ -8,6 +8,7 @@ import type { EmailFormFields, Screen } from '../types';
import
useApiFetch
from
'
lib/api/useApiFetch
'
;
import
useApiFetch
from
'
lib/api/useApiFetch
'
;
import
getErrorMessage
from
'
lib/errors/getErrorMessage
'
;
import
getErrorMessage
from
'
lib/errors/getErrorMessage
'
;
import
useToast
from
'
lib/hooks/useToast
'
;
import
useToast
from
'
lib/hooks/useToast
'
;
import
*
as
mixpanel
from
'
lib/mixpanel
'
;
import
FormFieldReCaptcha
from
'
ui/shared/forms/fields/FormFieldReCaptcha
'
;
import
FormFieldReCaptcha
from
'
ui/shared/forms/fields/FormFieldReCaptcha
'
;
import
AuthModalFieldEmail
from
'
../fields/AuthModalFieldEmail
'
;
import
AuthModalFieldEmail
from
'
../fields/AuthModalFieldEmail
'
;
...
@@ -15,9 +16,14 @@ import AuthModalFieldEmail from '../fields/AuthModalFieldEmail';
...
@@ -15,9 +16,14 @@ import AuthModalFieldEmail from '../fields/AuthModalFieldEmail';
interface
Props
{
interface
Props
{
onSubmit
:
(
screen
:
Screen
)
=>
void
;
onSubmit
:
(
screen
:
Screen
)
=>
void
;
isAuth
?:
boolean
;
isAuth
?:
boolean
;
mixpanelConfig
?:
{
account_link_info
:
{
source
:
mixpanel
.
EventPayload
<
mixpanel
.
EventTypes
.
ACCOUNT_LINK_INFO
>
[
'
Source
'
];
};
};
}
}
const
AuthModalScreenEmail
=
({
onSubmit
,
isAuth
}:
Props
)
=>
{
const
AuthModalScreenEmail
=
({
onSubmit
,
isAuth
,
mixpanelConfig
}:
Props
)
=>
{
const
apiFetch
=
useApiFetch
();
const
apiFetch
=
useApiFetch
();
const
toast
=
useToast
();
const
toast
=
useToast
();
...
@@ -40,6 +46,18 @@ const AuthModalScreenEmail = ({ onSubmit, isAuth }: Props) => {
...
@@ -40,6 +46,18 @@ const AuthModalScreenEmail = ({ onSubmit, isAuth }: Props) => {
},
},
})
})
.
then
(()
=>
{
.
then
(()
=>
{
if
(
isAuth
)
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
ACCOUNT_LINK_INFO
,
{
Source
:
mixpanelConfig
?.
account_link_info
.
source
??
'
Profile dropdown
'
,
Status
:
'
OTP sent
'
,
Type
:
'
Email
'
,
});
}
else
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
LOGIN
,
{
Action
:
'
OTP sent
'
,
Source
:
'
Email
'
,
});
}
onSubmit
({
type
:
'
otp_code
'
,
email
:
formData
.
email
,
isAuth
});
onSubmit
({
type
:
'
otp_code
'
,
email
:
formData
.
email
,
isAuth
});
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
...
@@ -49,7 +67,7 @@ const AuthModalScreenEmail = ({ onSubmit, isAuth }: Props) => {
...
@@ -49,7 +67,7 @@ const AuthModalScreenEmail = ({ onSubmit, isAuth }: Props) => {
description
:
getErrorMessage
(
error
)
||
'
Something went wrong
'
,
description
:
getErrorMessage
(
error
)
||
'
Something went wrong
'
,
});
});
});
});
},
[
apiFetch
,
onSubmit
,
toast
,
isAuth
]);
},
[
apiFetch
,
isAuth
,
onSubmit
,
mixpanelConfig
?.
account_link_info
.
source
,
toast
]);
return
(
return
(
<
FormProvider
{
...
formApi
}
>
<
FormProvider
{
...
formApi
}
>
...
...
ui/snippets/auth/screens/AuthModalScreenSelectMethod.tsx
View file @
8ef67799
...
@@ -3,6 +3,8 @@ import React from 'react';
...
@@ -3,6 +3,8 @@ import React from 'react';
import
type
{
Screen
}
from
'
../types
'
;
import
type
{
Screen
}
from
'
../types
'
;
import
*
as
mixpanel
from
'
lib/mixpanel
'
;
interface
Props
{
interface
Props
{
onSelectMethod
:
(
screen
:
Screen
)
=>
void
;
onSelectMethod
:
(
screen
:
Screen
)
=>
void
;
}
}
...
@@ -10,10 +12,18 @@ interface Props {
...
@@ -10,10 +12,18 @@ interface Props {
const
AuthModalScreenSelectMethod
=
({
onSelectMethod
}:
Props
)
=>
{
const
AuthModalScreenSelectMethod
=
({
onSelectMethod
}:
Props
)
=>
{
const
handleEmailClick
=
React
.
useCallback
(()
=>
{
const
handleEmailClick
=
React
.
useCallback
(()
=>
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
LOGIN
,
{
Action
:
'
Email
'
,
Source
:
'
Options selector
'
,
});
onSelectMethod
({
type
:
'
email
'
});
onSelectMethod
({
type
:
'
email
'
});
},
[
onSelectMethod
]);
},
[
onSelectMethod
]);
const
handleConnectWalletClick
=
React
.
useCallback
(()
=>
{
const
handleConnectWalletClick
=
React
.
useCallback
(()
=>
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
LOGIN
,
{
Action
:
'
Wallet
'
,
Source
:
'
Options selector
'
,
});
onSelectMethod
({
type
:
'
connect_wallet
'
});
onSelectMethod
({
type
:
'
connect_wallet
'
});
},
[
onSelectMethod
]);
},
[
onSelectMethod
]);
...
...
ui/snippets/auth/useLogout.ts
View file @
8ef67799
...
@@ -6,6 +6,7 @@ import type { Route } from 'nextjs-routes';
...
@@ -6,6 +6,7 @@ import type { Route } from 'nextjs-routes';
import
{
getResourceKey
}
from
'
lib/api/useApiQuery
'
;
import
{
getResourceKey
}
from
'
lib/api/useApiQuery
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
*
as
mixpanel
from
'
lib/mixpanel
'
;
const
PROTECTED_ROUTES
:
Array
<
Route
[
'
pathname
'
]
>
=
[
const
PROTECTED_ROUTES
:
Array
<
Route
[
'
pathname
'
]
>
=
[
'
/account/api-key
'
,
'
/account/api-key
'
,
...
@@ -28,6 +29,8 @@ export default function useLogout() {
...
@@ -28,6 +29,8 @@ export default function useLogout() {
exact
:
true
,
exact
:
true
,
});
});
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
ACCOUNT_ACCESS
,
{
Action
:
'
Logged out
'
},
{
send_immediately
:
true
});
if
(
if
(
PROTECTED_ROUTES
.
includes
(
router
.
pathname
)
||
PROTECTED_ROUTES
.
includes
(
router
.
pathname
)
||
(
router
.
pathname
===
'
/txs
'
&&
router
.
query
.
tab
===
'
watchlist
'
)
(
router
.
pathname
===
'
/txs
'
&&
router
.
query
.
tab
===
'
watchlist
'
)
...
...
ui/snippets/auth/useSignInWithWallet.ts
View file @
8ef67799
...
@@ -6,14 +6,16 @@ import config from 'configs/app';
...
@@ -6,14 +6,16 @@ import config from 'configs/app';
import
useApiFetch
from
'
lib/api/useApiFetch
'
;
import
useApiFetch
from
'
lib/api/useApiFetch
'
;
import
getErrorMessage
from
'
lib/errors/getErrorMessage
'
;
import
getErrorMessage
from
'
lib/errors/getErrorMessage
'
;
import
useToast
from
'
lib/hooks/useToast
'
;
import
useToast
from
'
lib/hooks/useToast
'
;
import
*
as
mixpanel
from
'
lib/mixpanel
'
;
import
useAccount
from
'
lib/web3/useAccount
'
;
import
useAccount
from
'
lib/web3/useAccount
'
;
interface
Props
{
interface
Props
{
onSuccess
?:
({
address
}:
{
address
:
string
})
=>
void
;
onSuccess
?:
({
address
}:
{
address
:
string
})
=>
void
;
onError
?:
()
=>
void
;
onError
?:
()
=>
void
;
source
?:
mixpanel
.
EventPayload
<
mixpanel
.
EventTypes
.
WALLET_CONNECT
>
[
'
Source
'
];
}
}
function
useSignInWithWallet
({
onSuccess
,
onError
}:
Props
)
{
function
useSignInWithWallet
({
onSuccess
,
onError
,
source
=
'
Login
'
}:
Props
)
{
const
[
isPending
,
setIsPending
]
=
React
.
useState
(
false
);
const
[
isPending
,
setIsPending
]
=
React
.
useState
(
false
);
const
isConnectingWalletRef
=
React
.
useRef
(
false
);
const
isConnectingWalletRef
=
React
.
useRef
(
false
);
...
@@ -54,15 +56,17 @@ function useSignInWithWallet({ onSuccess, onError }: Props) {
...
@@ -54,15 +56,17 @@ function useSignInWithWallet({ onSuccess, onError }: Props) {
}
else
{
}
else
{
isConnectingWalletRef
.
current
=
true
;
isConnectingWalletRef
.
current
=
true
;
web3Modal
.
open
();
web3Modal
.
open
();
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
WALLET_CONNECT
,
{
Source
:
source
,
Status
:
'
Started
'
});
}
}
},
[
address
,
proceedToAuth
,
web3Modal
]);
},
[
address
,
proceedToAuth
,
source
,
web3Modal
]);
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
address
&&
isConnectingWalletRef
.
current
)
{
if
(
address
&&
isConnectingWalletRef
.
current
)
{
isConnectingWalletRef
.
current
=
false
;
isConnectingWalletRef
.
current
=
false
;
proceedToAuth
(
address
);
proceedToAuth
(
address
);
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
WALLET_CONNECT
,
{
Source
:
source
,
Status
:
'
Connected
'
});
}
}
},
[
address
,
isConnected
,
proceedToAuth
]);
},
[
address
,
isConnected
,
proceedToAuth
,
source
]);
return
React
.
useMemo
(()
=>
({
start
,
isPending
}),
[
start
,
isPending
]);
return
React
.
useMemo
(()
=>
({
start
,
isPending
}),
[
start
,
isPending
]);
}
}
...
...
ui/snippets/user/profile/UserProfileButton.tsx
View file @
8ef67799
...
@@ -63,16 +63,12 @@ const UserProfileButton = ({ profileQuery, size, variant, onClick, isPending }:
...
@@ -63,16 +63,12 @@ const UserProfileButton = ({ profileQuery, size, variant, onClick, isPending }:
);
);
}
}
if
(
data
.
email
)
{
return
(
return
(
<
HStack
gap=
{
2
}
>
<
HStack
gap=
{
2
}
>
<
IconSvg
name=
"profile"
boxSize=
{
5
}
/>
<
IconSvg
name=
"profile"
boxSize=
{
5
}
/>
<
Box
display=
{
{
base
:
'
none
'
,
md
:
'
block
'
}
}
>
{
getUserHandle
(
data
.
email
)
}
</
Box
>
<
Box
display=
{
{
base
:
'
none
'
,
md
:
'
block
'
}
}
>
{
data
.
email
?
getUserHandle
(
data
.
email
)
:
'
Profile
'
}
</
Box
>
</
HStack
>
</
HStack
>
);
);
}
return
'
Connected
'
;
})();
})();
return
(
return
(
...
...
ui/snippets/user/profile/UserProfileContentWallet.tsx
View file @
8ef67799
...
@@ -12,7 +12,7 @@ interface Props {
...
@@ -12,7 +12,7 @@ interface Props {
}
}
const
UserProfileContentWallet
=
({
onClose
}:
Props
)
=>
{
const
UserProfileContentWallet
=
({
onClose
}:
Props
)
=>
{
const
web3Wallet
=
useWeb3Wallet
({
source
:
'
Header
'
});
const
web3Wallet
=
useWeb3Wallet
({
source
:
'
Profile dropdown
'
});
const
web3AccountWithDomain
=
useWeb3AccountWithDomain
(
true
);
const
web3AccountWithDomain
=
useWeb3AccountWithDomain
(
true
);
...
...
ui/snippets/user/profile/UserProfileDesktop.tsx
View file @
8ef67799
...
@@ -5,6 +5,7 @@ import React from 'react';
...
@@ -5,6 +5,7 @@ import React from 'react';
import
type
{
Screen
}
from
'
ui/snippets/auth/types
'
;
import
type
{
Screen
}
from
'
ui/snippets/auth/types
'
;
import
config
from
'
configs/app
'
;
import
config
from
'
configs/app
'
;
import
*
as
mixpanel
from
'
lib/mixpanel
'
;
import
Popover
from
'
ui/shared/chakra/Popover
'
;
import
Popover
from
'
ui/shared/chakra/Popover
'
;
import
AuthModal
from
'
ui/snippets/auth/AuthModal
'
;
import
AuthModal
from
'
ui/snippets/auth/AuthModal
'
;
import
useProfileQuery
from
'
ui/snippets/auth/useProfileQuery
'
;
import
useProfileQuery
from
'
ui/snippets/auth/useProfileQuery
'
;
...
@@ -32,6 +33,7 @@ const UserProfileDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) =>
...
@@ -32,6 +33,7 @@ const UserProfileDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) =>
const
handleProfileButtonClick
=
React
.
useCallback
(()
=>
{
const
handleProfileButtonClick
=
React
.
useCallback
(()
=>
{
if
(
profileQuery
.
data
)
{
if
(
profileQuery
.
data
)
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
ACCOUNT_ACCESS
,
{
Action
:
'
Dropdown open
'
});
profileMenu
.
onOpen
();
profileMenu
.
onOpen
();
return
;
return
;
}
}
...
...
ui/snippets/user/profile/UserProfileMobile.tsx
View file @
8ef67799
...
@@ -5,6 +5,7 @@ import React from 'react';
...
@@ -5,6 +5,7 @@ import React from 'react';
import
type
{
Screen
}
from
'
ui/snippets/auth/types
'
;
import
type
{
Screen
}
from
'
ui/snippets/auth/types
'
;
import
config
from
'
configs/app
'
;
import
config
from
'
configs/app
'
;
import
*
as
mixpanel
from
'
lib/mixpanel
'
;
import
AuthModal
from
'
ui/snippets/auth/AuthModal
'
;
import
AuthModal
from
'
ui/snippets/auth/AuthModal
'
;
import
useProfileQuery
from
'
ui/snippets/auth/useProfileQuery
'
;
import
useProfileQuery
from
'
ui/snippets/auth/useProfileQuery
'
;
import
useSignInWithWallet
from
'
ui/snippets/auth/useSignInWithWallet
'
;
import
useSignInWithWallet
from
'
ui/snippets/auth/useSignInWithWallet
'
;
...
@@ -26,6 +27,7 @@ const UserProfileMobile = () => {
...
@@ -26,6 +27,7 @@ const UserProfileMobile = () => {
const
handleProfileButtonClick
=
React
.
useCallback
(()
=>
{
const
handleProfileButtonClick
=
React
.
useCallback
(()
=>
{
if
(
profileQuery
.
data
)
{
if
(
profileQuery
.
data
)
{
mixpanel
.
logEvent
(
mixpanel
.
EventTypes
.
ACCOUNT_ACCESS
,
{
Action
:
'
Dropdown open
'
});
profileMenu
.
onOpen
();
profileMenu
.
onOpen
();
return
;
return
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment