Skip to content
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

fix: Add missing safe creation events #1212

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/create-safe/InfoWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { ReactElement } from 'react'
import LightbulbIcon from '@/public/images/common/lightbulb.svg'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import css from './styles.module.css'
import { CREATE_SAFE_EVENTS, trackEvent } from '@/services/analytics'

type InfoWidgetProps = {
title: string
Expand Down Expand Up @@ -51,7 +52,12 @@ const InfoWidget = ({ title, steps, variant, startExpanded = false }: InfoWidget
<CardContent>
{steps.map(({ title, text }) => {
return (
<Accordion key={title} className={css.tipAccordion} defaultExpanded={startExpanded}>
<Accordion
key={title}
className={css.tipAccordion}
defaultExpanded={startExpanded}
onChange={(e, expanded) => expanded && trackEvent({ ...CREATE_SAFE_EVENTS.OPEN_HINT, label: title })}
>
<AccordionSummary
expandIcon={
<IconButton sx={{ '&:hover': { background: ({ palette }) => palette[variant]?.light } }}>
Expand Down
2 changes: 2 additions & 0 deletions src/components/create-safe/status/useSafeCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useCurrentChain } from '@/hooks/useChains'
import useWallet from '@/hooks/wallets/useWallet'
import type { PendingSafeData, PendingSafeTx } from '@/components/create-safe/types.d'
import type { EthersError } from '@/utils/ethers-utils'
import { CREATE_SAFE_EVENTS, trackEvent } from '@/services/analytics'

export enum SafeCreationStatus {
AWAITING = 'AWAITING',
Expand Down Expand Up @@ -40,6 +41,7 @@ export const useSafeCreation = (

const createSafeCallback = useCallback(
async (txHash: string, tx: PendingSafeTx) => {
trackEvent(CREATE_SAFE_EVENTS.SUBMIT_CREATE_SAFE)
setPendingSafe((prev) => (prev ? { ...prev, txHash, tx } : undefined))
},
[setPendingSafe],
Expand Down
5 changes: 5 additions & 0 deletions src/components/new-safe/steps/Step1/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import layoutCss from '@/components/new-safe/CreateSafe/styles.module.css'
import useIsWrongChain from '@/hooks/useIsWrongChain'
import NetworkWarning from '@/components/new-safe/NetworkWarning'
import NameInput from '@/components/common/NameInput'
import { CREATE_SAFE_EVENTS, trackEvent } from '@/services/analytics'

type CreateSafeStep1Form = {
name: string
Expand Down Expand Up @@ -49,6 +50,10 @@ function CreateSafeStep1({
const name = data.name || fallbackName
setSafeName(name)
onSubmit({ ...data, name })

if (data.name) {
trackEvent(CREATE_SAFE_EVENTS.NAME_SAFE)
}
}

const isDisabled = isWrongChain || !isValid
Expand Down
17 changes: 16 additions & 1 deletion src/components/new-safe/steps/Step2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import css from './styles.module.css'
import layoutCss from '@/components/new-safe/CreateSafe/styles.module.css'
import NetworkWarning from '@/components/new-safe/NetworkWarning'
import useIsWrongChain from '@/hooks/useIsWrongChain'
import { CREATE_SAFE_EVENTS, trackEvent } from '@/services/analytics'

enum CreateSafeStep2Fields {
owners = 'owners',
Expand Down Expand Up @@ -74,8 +75,22 @@ const CreateSafeStep2 = ({
onBack(formData)
}

const onFormSubmit = handleSubmit((data) => {
onSubmit(data)

trackEvent({
...CREATE_SAFE_EVENTS.OWNERS,
label: data.owners.length,
})

trackEvent({
...CREATE_SAFE_EVENTS.THRESHOLD,
label: data.threshold,
})
})

return (
<form onSubmit={handleSubmit(onSubmit)} id={STEP_2_FORM_ID}>
<form onSubmit={onFormSubmit} id={STEP_2_FORM_ID}>
<FormProvider {...formMethods}>
<Box className={layoutCss.row}>
{ownerFields.map((field, i) => (
Expand Down
2 changes: 2 additions & 0 deletions src/components/new-safe/steps/Step4/useSafeCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '@/components/new-safe/steps/Step4/logic'
import { useAppDispatch } from '@/store'
import { closeByGroupKey } from '@/store/notificationsSlice'
import { CREATE_SAFE_EVENTS, trackEvent } from '@/services/analytics'

export enum SafeCreationStatus {
AWAITING,
Expand Down Expand Up @@ -46,6 +47,7 @@ export const useSafeCreation = (

const createSafeCallback = useCallback(
async (txHash: string, tx: PendingSafeTx) => {
trackEvent(CREATE_SAFE_EVENTS.SUBMIT_CREATE_SAFE)
setPendingSafe((prev) => (prev ? { ...prev, txHash, tx } : undefined))
},
[setPendingSafe],
Expand Down
4 changes: 4 additions & 0 deletions src/services/analytics/events/createLoadSafe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export const CREATE_SAFE_EVENTS = {
action: 'Open Safe',
category: CREATE_SAFE_CATEGORY,
},
OPEN_HINT: {
action: 'Open Hint',
category: CREATE_SAFE_CATEGORY,
},
}

export const LOAD_SAFE_CATEGORY = 'load-safe'
Expand Down