Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rickykuo666 committed Aug 7, 2024
1 parent 6ddb343 commit 855048c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
14 changes: 13 additions & 1 deletion components/AccountBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ export const AccountBody = ({
{accountInfo?.type === 'user' && stakingOpsStatus.Delegated && (
<End
onClick={() => {
trackGAEvent(
GAAction.BUTTON_CLICK,
GACategory.END_DELEGATE_BEGIN
)
endDelegateModal.onOpen()
}}
/>
Expand All @@ -252,7 +256,15 @@ export const AccountBody = ({
</Text>
{accountInfo?.type === 'user' &&
(stakingOpsStatus.Delegated ? (
<Change onClick={() => changeBakerModal.onOpen()} />
<Change
onClick={() => {
trackGAEvent(
GAAction.BUTTON_CLICK,
GACategory.CHOOSE_CHANGE_BAKER
)
changeBakerModal.onOpen()
}}
/>
) : (
<ViewBakers />
))}
Expand Down
2 changes: 2 additions & 0 deletions components/operationModals/ChangeBaker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const ChangeBakerModal = ({
handleOneStepBack={handleOneStepBack}
selectedBaker={selectedBaker as BakerInfo}
setSelectedBaker={setSelectedBaker}
isChangeBaker={true}
/>
)
default:
Expand All @@ -92,6 +93,7 @@ export const ChangeBakerModal = ({
handleOneStepBack={handleOneStepBack}
selectedBaker={selectedBaker as BakerInfo}
setSelectedBaker={setSelectedBaker}
isChangeBaker={true}
/>
)
default:
Expand Down
13 changes: 11 additions & 2 deletions components/operationModals/Delegate/ConfirmBaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 } =
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions components/operationModals/EndDelegate/ConfirmEndDelegate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 8 additions & 1 deletion utils/trackGAEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 855048c

Please sign in to comment.