From 08410b524308b27fc9ab610efdaa2eb424dc040d Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Mon, 21 Nov 2022 15:43:53 +0100 Subject: [PATCH 1/2] fix: Add missing safe creation events --- .../create-safe/status/useSafeCreation.ts | 2 ++ src/components/new-safe/steps/Step1/index.tsx | 5 +++++ src/components/new-safe/steps/Step2/index.tsx | 17 ++++++++++++++++- .../new-safe/steps/Step4/useSafeCreation.ts | 2 ++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/components/create-safe/status/useSafeCreation.ts b/src/components/create-safe/status/useSafeCreation.ts index eadbbdcd20..0e50c26037 100644 --- a/src/components/create-safe/status/useSafeCreation.ts +++ b/src/components/create-safe/status/useSafeCreation.ts @@ -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', @@ -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], diff --git a/src/components/new-safe/steps/Step1/index.tsx b/src/components/new-safe/steps/Step1/index.tsx index 97fc717e04..5f3ea61e4f 100644 --- a/src/components/new-safe/steps/Step1/index.tsx +++ b/src/components/new-safe/steps/Step1/index.tsx @@ -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 @@ -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 diff --git a/src/components/new-safe/steps/Step2/index.tsx b/src/components/new-safe/steps/Step2/index.tsx index b6d3bae20d..f03e83f39c 100644 --- a/src/components/new-safe/steps/Step2/index.tsx +++ b/src/components/new-safe/steps/Step2/index.tsx @@ -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', @@ -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 ( -
+ {ownerFields.map((field, i) => ( diff --git a/src/components/new-safe/steps/Step4/useSafeCreation.ts b/src/components/new-safe/steps/Step4/useSafeCreation.ts index 11845e7c52..3176d52cef 100644 --- a/src/components/new-safe/steps/Step4/useSafeCreation.ts +++ b/src/components/new-safe/steps/Step4/useSafeCreation.ts @@ -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, @@ -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], From fb1b87a258b901f7e254e7e246e433ef98f58981 Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Mon, 21 Nov 2022 15:57:35 +0100 Subject: [PATCH 2/2] fix: Add new events for hints --- src/components/create-safe/InfoWidget/index.tsx | 8 +++++++- src/services/analytics/events/createLoadSafe.ts | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/create-safe/InfoWidget/index.tsx b/src/components/create-safe/InfoWidget/index.tsx index c0d4c6ac4c..1dfdbf9293 100644 --- a/src/components/create-safe/InfoWidget/index.tsx +++ b/src/components/create-safe/InfoWidget/index.tsx @@ -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 @@ -51,7 +52,12 @@ const InfoWidget = ({ title, steps, variant, startExpanded = false }: InfoWidget {steps.map(({ title, text }) => { return ( - + expanded && trackEvent({ ...CREATE_SAFE_EVENTS.OPEN_HINT, label: title })} + > palette[variant]?.light } }}> diff --git a/src/services/analytics/events/createLoadSafe.ts b/src/services/analytics/events/createLoadSafe.ts index e210008f20..98689a083d 100644 --- a/src/services/analytics/events/createLoadSafe.ts +++ b/src/services/analytics/events/createLoadSafe.ts @@ -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'