Skip to content

Commit

Permalink
[Multichain] fix: Add more analytics events for multichain [SW-165] (#…
Browse files Browse the repository at this point in the history
…4311)

* fix: Add more analytics events for multichain

* fix: Remove event from SubAccountItem
  • Loading branch information
usame-algan authored Oct 7, 2024
1 parent fcaa83e commit 67e8423
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/components/common/NetworkSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { useRouter } from 'next/router'
import css from './styles.module.css'
import { useChainId } from '@/hooks/useChainId'
import { type ReactElement, useCallback, useMemo, useState } from 'react'
import { OVERVIEW_EVENTS, OVERVIEW_LABELS } from '@/services/analytics'
import { OVERVIEW_EVENTS, OVERVIEW_LABELS, trackEvent } from '@/services/analytics'

import { useAllSafesGrouped } from '@/components/welcome/MyAccounts/useAllSafesGrouped'
import useSafeAddress from '@/hooks/useSafeAddress'
Expand Down Expand Up @@ -327,12 +327,17 @@ const NetworkSelector = ({
const chain = chains.data.find((chain) => chain.chainId === chainId)
if (!chain) return null

const onSwitchNetwork = () => {
trackEvent({ ...OVERVIEW_EVENTS.SWITCH_NETWORK, label: chainId })
}

return (
<MenuItem
key={chainId}
value={chainId}
sx={{ '&:hover': { backgroundColor: isSelected ? 'transparent' : 'inherit' } }}
disableRipple={isSelected}
onClick={onSwitchNetwork}
>
<Link
href={getNetworkLink(router, safeAddress, chain.shortName)}
Expand All @@ -353,6 +358,7 @@ const NetworkSelector = ({

const handleOpen = () => {
setOpen(true)
offerSafeCreation && trackEvent({ ...OVERVIEW_EVENTS.EXPAND_MULTI_SAFE, label: OVERVIEW_LABELS.top_bar })
}

return configs.length ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ModalDialog from '@/components/common/ModalDialog'
import NetworkInput from '@/components/common/NetworkInput'
import ErrorMessage from '@/components/tx/ErrorMessage'
import { OVERVIEW_EVENTS, trackEvent } from '@/services/analytics'
import { CREATE_SAFE_CATEGORY, CREATE_SAFE_EVENTS, OVERVIEW_EVENTS, trackEvent } from '@/services/analytics'
import { showNotification } from '@/store/notificationsSlice'
import { Box, Button, CircularProgress, DialogActions, DialogContent, Stack, Typography } from '@mui/material'
import { FormProvider, useForm } from 'react-hook-form'
Expand Down Expand Up @@ -95,7 +95,7 @@ const ReplaySafeDialog = ({
return
}

trackEvent({ ...OVERVIEW_EVENTS.SUBMIT_ADD_NEW_NETWORK, label: selectedChain.chainName })
trackEvent({ ...OVERVIEW_EVENTS.SUBMIT_ADD_NEW_NETWORK, label: selectedChain.chainId })

// 2. Replay Safe creation and add it to the counterfactual Safes
replayCounterfactualSafeDeployment(
Expand All @@ -107,6 +107,9 @@ const ReplaySafeDialog = ({
PayMethod.PayLater,
)

trackEvent({ ...OVERVIEW_EVENTS.PROCEED_WITH_TX, label: 'counterfactual', category: CREATE_SAFE_CATEGORY })
trackEvent({ ...CREATE_SAFE_EVENTS.CREATED_SAFE, label: 'counterfactual' })

router.push({
query: {
safe: `${selectedChain.shortName}:${safeAddress}`,
Expand Down

0 comments on commit 67e8423

Please sign in to comment.