From 855048c7121c0b7b679d1692a21d38a48ebfb5c4 Mon Sep 17 00:00:00 2001 From: rickykuo666 Date: Wed, 7 Aug 2024 12:17:54 +0100 Subject: [PATCH] wip --- components/AccountBody.tsx | 14 +++++++++++++- components/operationModals/ChangeBaker/index.tsx | 2 ++ .../operationModals/Delegate/ConfirmBaker.tsx | 13 +++++++++++-- .../EndDelegate/ConfirmEndDelegate.tsx | 2 ++ utils/trackGAEvent.ts | 9 ++++++++- 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/components/AccountBody.tsx b/components/AccountBody.tsx index 69d9eea..aac2ede 100644 --- a/components/AccountBody.tsx +++ b/components/AccountBody.tsx @@ -229,6 +229,10 @@ export const AccountBody = ({ {accountInfo?.type === 'user' && stakingOpsStatus.Delegated && ( { + trackGAEvent( + GAAction.BUTTON_CLICK, + GACategory.END_DELEGATE_BEGIN + ) endDelegateModal.onOpen() }} /> @@ -252,7 +256,15 @@ export const AccountBody = ({ {accountInfo?.type === 'user' && (stakingOpsStatus.Delegated ? ( - changeBakerModal.onOpen()} /> + { + trackGAEvent( + GAAction.BUTTON_CLICK, + GACategory.CHOOSE_CHANGE_BAKER + ) + changeBakerModal.onOpen() + }} + /> ) : ( ))} diff --git a/components/operationModals/ChangeBaker/index.tsx b/components/operationModals/ChangeBaker/index.tsx index ef865d0..774c5f9 100644 --- a/components/operationModals/ChangeBaker/index.tsx +++ b/components/operationModals/ChangeBaker/index.tsx @@ -68,6 +68,7 @@ export const ChangeBakerModal = ({ handleOneStepBack={handleOneStepBack} selectedBaker={selectedBaker as BakerInfo} setSelectedBaker={setSelectedBaker} + isChangeBaker={true} /> ) default: @@ -92,6 +93,7 @@ export const ChangeBakerModal = ({ handleOneStepBack={handleOneStepBack} selectedBaker={selectedBaker as BakerInfo} setSelectedBaker={setSelectedBaker} + isChangeBaker={true} /> ) default: diff --git a/components/operationModals/Delegate/ConfirmBaker.tsx b/components/operationModals/Delegate/ConfirmBaker.tsx index bc7c493..adde104 100644 --- a/components/operationModals/Delegate/ConfirmBaker.tsx +++ b/components/operationModals/Delegate/ConfirmBaker.tsx @@ -26,13 +26,15 @@ interface ChooseBakerProps { handleOneStepBack: () => void selectedBaker: BakerInfo setSelectedBaker: (b: null) => void + isChangeBaker?: boolean } export const ConfirmBaker = ({ handleOneStepForward, handleOneStepBack, selectedBaker, - setSelectedBaker + setSelectedBaker, + isChangeBaker }: ChooseBakerProps) => { const { Tezos, beaconWallet } = useConnection() const { setMessage, setSuccess, setOpHash, setOpType } = @@ -119,7 +121,14 @@ export const ConfirmBaker = ({ ) setWaitingOperation(false) if (response.success) { - trackGAEvent(GAAction.BUTTON_CLICK, GACategory.START_DELEGATE_END) + if (isChangeBaker) + trackGAEvent( + GAAction.BUTTON_CLICK, + GACategory.CHANGE_BAKER_SUCCESS + ) + else + trackGAEvent(GAAction.BUTTON_CLICK, GACategory.START_DELEGATE_END) + setOpHash(response.opHash) setOpType('delegate') setMessage( diff --git a/components/operationModals/EndDelegate/ConfirmEndDelegate.tsx b/components/operationModals/EndDelegate/ConfirmEndDelegate.tsx index 6c8c7a1..5070fb2 100644 --- a/components/operationModals/EndDelegate/ConfirmEndDelegate.tsx +++ b/components/operationModals/EndDelegate/ConfirmEndDelegate.tsx @@ -6,6 +6,7 @@ import { useConnection } from '@/providers/ConnectionProvider' import { AddressBox, Header, ColumnHeader } from '@/components/modalBody' import { useOperationResponse } from '@/providers/OperationResponseProvider' import { ErrorBlock } from '@/components/ErrorBlock' +import { trackGAEvent, GAAction, GACategory } from '@/utils/trackGAEvent' interface ConfirmEndDelegate { spendableBalance: number @@ -39,6 +40,7 @@ export const ConfirmEndDelegate = ({ const response = await setDelegate(Tezos, undefined, beaconWallet) setWaitingOperation(false) if (response.success) { + trackGAEvent(GAAction.BUTTON_CLICK, GACategory.END_DELEGATE_END) setOpHash(response.opHash) setTitle('Delegation Ended!') setMessage( diff --git a/utils/trackGAEvent.ts b/utils/trackGAEvent.ts index 8eaa382..c4ce329 100644 --- a/utils/trackGAEvent.ts +++ b/utils/trackGAEvent.ts @@ -8,13 +8,20 @@ export enum GACategory { WALLET_BEGIN = 'wallet_begin', WALLET_SUCCESS = 'wallet_success', WALLET_ERROR = 'wallet_error', + CHOOSE_BAKER_START = 'choose_baker_start', CONTINUE_DELEGATION = 'continue_delegation', CHOOSE_BAKER_SUCCESS = 'choose_baker_succcess', CHOOSE_BAKER_CLOSED = 'choose_baker_closed', START_DELEGATE_BEGIN = 'start_delegate_begin', START_DELEGATE_END = 'start_delegate_end', - CONTINUE_AFTER_DELEGATION = 'continue_after_delegation' + CONTINUE_AFTER_DELEGATION = 'continue_after_delegation', + + CHOOSE_CHANGE_BAKER = 'choose_change_baker', + CHANGE_BAKER_SUCCESS = 'change_baker_success', + + END_DELEGATE_BEGIN = 'end_delegate_begin', + END_DELEGATE_END = 'end_delegate_end' } export const trackGAEvent = (action: GAAction, category: GACategory) => {