From 9c42dde801f77f4895807576986e9300b0c663e1 Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Tue, 7 Nov 2023 15:50:16 +0100 Subject: [PATCH] fix: Add events for export pk --- .../ExportMPCAccountModal.tsx | 24 ++++++++++----- .../SocialSignerExport/index.tsx | 29 ++++++++++++------- src/services/analytics/events/mpcWallet.ts | 25 ++++++++++++++++ 3 files changed, 60 insertions(+), 18 deletions(-) diff --git a/src/components/settings/SecurityLogin/SocialSignerExport/ExportMPCAccountModal.tsx b/src/components/settings/SecurityLogin/SocialSignerExport/ExportMPCAccountModal.tsx index ffb7cb461d..bacce6a38f 100644 --- a/src/components/settings/SecurityLogin/SocialSignerExport/ExportMPCAccountModal.tsx +++ b/src/components/settings/SecurityLogin/SocialSignerExport/ExportMPCAccountModal.tsx @@ -1,5 +1,7 @@ import CopyButton from '@/components/common/CopyButton' import ModalDialog from '@/components/common/ModalDialog' +import { trackEvent } from '@/services/analytics' +import { MPC_WALLET_EVENTS } from '@/services/analytics/events/mpcWallet' import { Box, Button, DialogContent, DialogTitle, IconButton, TextField, Typography } from '@mui/material' import { useState } from 'react' import { useForm } from 'react-hook-form' @@ -43,9 +45,11 @@ const ExportMPCAccountModal = ({ onClose, open }: { onClose: () => void; open: b try { setError(undefined) const pk = await socialWalletService.exportSignerKey(data[ExportFieldNames.password]) + trackEvent(MPC_WALLET_EVENTS.EXPORT_PK_SUCCESS) setValue(ExportFieldNames.pk, pk) } catch (err) { logError(ErrorCodes._305, err) + trackEvent(MPC_WALLET_EVENTS.EXPORT_PK_ERROR) setError(asError(err).message) } } @@ -55,13 +59,19 @@ const ExportMPCAccountModal = ({ onClose, open }: { onClose: () => void; open: b reset() onClose() } + + const toggleShowPK = () => { + trackEvent(MPC_WALLET_EVENTS.SEE_PK) + setShowPassword((prev) => !prev) + } + + const onCopy = () => { + trackEvent(MPC_WALLET_EVENTS.COPY_PK) + } + return ( - - - Export your account - - + Export your account @@ -83,10 +93,10 @@ const ExportMPCAccountModal = ({ onClose, open }: { onClose: () => void; open: b readOnly: true, endAdornment: ( <> - setShowPassword((prev) => !prev)}> + {showPassword ? : } - + ), }} diff --git a/src/components/settings/SecurityLogin/SocialSignerExport/index.tsx b/src/components/settings/SecurityLogin/SocialSignerExport/index.tsx index c73a0b7af1..088e484af2 100644 --- a/src/components/settings/SecurityLogin/SocialSignerExport/index.tsx +++ b/src/components/settings/SecurityLogin/SocialSignerExport/index.tsx @@ -1,3 +1,5 @@ +import Track from '@/components/common/Track' +import { MPC_WALLET_EVENTS } from '@/services/analytics/events/mpcWallet' import { Alert, Box, Button, Tooltip, Typography } from '@mui/material' import { useState } from 'react' import ExportMPCAccountModal from '@/components/settings/SecurityLogin/SocialSignerExport/ExportMPCAccountModal' @@ -20,17 +22,22 @@ const SocialSignerExport = () => { Never disclose your keys or seed phrase to anyone. If someone gains access to them, they have full access over your social login signer. - - - + + + + + + + + setIsModalOpen(false)} open={isModalOpen} /> diff --git a/src/services/analytics/events/mpcWallet.ts b/src/services/analytics/events/mpcWallet.ts index 5f3277c789..8e20e29de2 100644 --- a/src/services/analytics/events/mpcWallet.ts +++ b/src/services/analytics/events/mpcWallet.ts @@ -28,4 +28,29 @@ export const MPC_WALLET_EVENTS = { action: 'Enable MFA for account', category: MPC_WALLET_CATEGORY, }, + REVEAL_PRIVATE_KEY: { + event: EventType.CLICK, + action: 'Reveal private key', + category: MPC_WALLET_CATEGORY, + }, + EXPORT_PK_SUCCESS: { + event: EventType.META, + action: 'Export private key successful', + category: MPC_WALLET_CATEGORY, + }, + EXPORT_PK_ERROR: { + event: EventType.META, + action: 'Export private key error', + category: MPC_WALLET_CATEGORY, + }, + SEE_PK: { + event: EventType.CLICK, + action: 'Toggle see private key', + category: MPC_WALLET_CATEGORY, + }, + COPY_PK: { + event: EventType.CLICK, + action: 'Copy private key', + category: MPC_WALLET_CATEGORY, + }, }