Skip to content

Commit

Permalink
feat: further event tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Aug 15, 2024
1 parent 673f367 commit 2b80cf7
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,17 @@ export const PositionActionButtons = ({
requestedAccount={activeGroup.selectedAccount ?? undefined}
activeGroupArg={activeGroup}
>
<Button variant="outline" size="sm" className="gap-1 min-w-16">
<Button
variant="outline"
size="sm"
className="gap-1 min-w-16"
onClick={() => {
capture("position_add_btn_click", {
group: activeGroup?.groupPk?.toBase58(),
token: activeGroup.pool.token.meta.tokenSymbol,
});
}}
>
<IconPlus size={14} />
Add
</Button>
Expand All @@ -236,7 +246,17 @@ export const PositionActionButtons = ({
requestedAccount={activeGroup.selectedAccount ?? undefined}
activeGroupArg={activeGroup}
>
<Button variant="outline" size="sm" className="gap-1 min-w-16">
<Button
variant="outline"
size="sm"
className="gap-1 min-w-16"
onClick={() => {
capture("position_reduce_btn_click", {
group: activeGroup?.groupPk?.toBase58(),
token: activeGroup.pool.token.meta.tokenSymbol,
});
}}
>
<IconMinus size={14} />
Reduce
</Button>
Expand All @@ -250,7 +270,17 @@ export const PositionActionButtons = ({
requestedAccount={activeGroup.selectedAccount ?? undefined}
requestedCollateralBank={depositBanks.length > 1 ? depositBanks[1] : undefined}
>
<Button variant="outline" size="sm" className="gap-1 min-w-16">
<Button
variant="outline"
size="sm"
className="gap-1 min-w-16"
onClick={() => {
capture("position_withdraw_btn_click", {
group: activeGroup?.groupPk?.toBase58(),
token: activeGroup.pool.token.meta.tokenSymbol,
});
}}
>
<IconMinus size={14} />
Withdraw
</Button>
Expand Down
26 changes: 23 additions & 3 deletions apps/marginfi-v2-trading/src/components/common/Yield/YieldCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { aprToApy, numeralFormatter, percentFormatter, usdFormatter } from "@mrg
import { ActionType } from "@mrgnlabs/marginfi-v2-ui-state";

import { ArenaBank, GroupData } from "~/store/tradeStore";
import { getTokenImageURL, cn, getGroupPositionInfo } from "~/utils";
import { getTokenImageURL, cn, getGroupPositionInfo, capture } from "~/utils";

import { ActionBoxDialog } from "~/components/common/ActionBox";
import { Button } from "~/components/ui/button";
Expand Down Expand Up @@ -131,7 +131,17 @@ const YieldItem = ({
<div className="flex gap-2">
{bank.isActive && isLeveraged && bank.position.isLending && (
<ActionBoxDialog activeGroupArg={group} requestedBank={bank} requestedAction={ActionType.Withdraw}>
<Button className="w-full bg-background border text-foreground hover:bg-accent">Withdraw</Button>
<Button
className="w-full bg-background border text-foreground hover:bg-accent"
onClick={() => {
capture("yield_withdraw_btn_click", {
group: group.client.group.address.toBase58(),
bank: bank.meta.tokenSymbol,
});
}}
>
Withdraw
</Button>
</ActionBoxDialog>
)}
<ActionBoxDialog activeGroupArg={group} requestedBank={group.pool.token} requestedAction={ActionType.Deposit}>
Expand All @@ -154,7 +164,17 @@ const YieldItem = ({
</TooltipContent>
</Tooltip>
) : (
<Button className="w-full bg-background border text-foreground hover:bg-accent">Supply</Button>
<Button
className="w-full bg-background border text-foreground hover:bg-accent"
onClick={() => {
capture("yield_supply_btn_click", {
group: group.client.group.address.toBase58(),
bank: bank.meta.tokenSymbol,
});
}}
>
Supply
</Button>
)}
</ActionBoxDialog>
</div>
Expand Down
26 changes: 23 additions & 3 deletions apps/marginfi-v2-trading/src/components/common/Yield/YieldRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ActionType } from "@mrgnlabs/marginfi-v2-ui-state";

import { useTradeStore } from "~/store";
import { ArenaBank, GroupData } from "~/store/tradeStore";
import { getTokenImageURL, cn, getGroupPositionInfo } from "~/utils";
import { getTokenImageURL, cn, getGroupPositionInfo, capture } from "~/utils";
import { useWalletContext } from "~/hooks/useWalletContext";

import { ActionBoxDialog } from "~/components/common/ActionBox";
Expand Down Expand Up @@ -162,7 +162,17 @@ const YieldItem = ({
requestedAction={ActionType.Withdraw}
requestedAccount={group.selectedAccount}
>
<Button className="bg-background border text-foreground hover:bg-accent">Withdraw</Button>
<Button
className="bg-background border text-foreground hover:bg-accent"
onClick={() => {
capture("yield_withdraw_btn_click", {
group: group.client.group.address.toBase58(),
bank: bank.meta.tokenSymbol,
});
}}
>
Withdraw
</Button>
</ActionBoxDialog>
)}
<ActionBoxDialog
Expand Down Expand Up @@ -190,7 +200,17 @@ const YieldItem = ({
</TooltipContent>
</Tooltip>
) : (
<Button className="bg-background border text-foreground hover:bg-accent">Supply</Button>
<Button
className="bg-background border text-foreground hover:bg-accent"
onClick={() => {
capture("yield_supply_btn_click", {
group: group.client.group.address.toBase58(),
bank: bank.meta.tokenSymbol,
});
}}
>
Supply
</Button>
)}
</ActionBoxDialog>
</div>
Expand Down

0 comments on commit 2b80cf7

Please sign in to comment.