Skip to content

Commit

Permalink
chore: store ph user props
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Dec 1, 2023
1 parent 6afd19e commit ab6acad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/marginfi-v2-ui/src/components/common/Wallet/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from "react";
import { LAMPORTS_PER_SOL, GetProgramAccountsFilter, PublicKey } from "@solana/web3.js";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { CopyToClipboard } from "react-copy-to-clipboard";
import posthog from "posthog-js";

import { shortenAddress, usdFormatter, numeralFormatter } from "@mrgnlabs/mrgn-common";

Expand Down Expand Up @@ -86,6 +87,15 @@ export const Wallet = () => {
balanceSOL: solBank ? numeralFormatter(totalBalance / solBank?.info.state.price) : "0.00",
tokens: (tokens || []) as Token[],
});

posthog.setPersonProperties({
walletAddress: wallet?.publicKey.toString(),
tokens: tokens.map((token) => ({
name: token?.name,
symbol: token?.symbol,
value: token?.value,
})),
});
}, [connection, wallet?.publicKey, address, solBank]);

// fetch token accounts for wallet
Expand Down
5 changes: 5 additions & 0 deletions apps/marginfi-v2-ui/src/utils/mrgnActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ async function createAccountAndDeposit({
try {
await marginfiAccount.deposit(amount, bank.address);
multiStepToast.setSuccessAndNext();
posthog.capture("user_deposit", {
amount,
bankAddress: bank.address.toBase58(),
tokenSymbol: bank.meta.tokenSymbol,
});
} catch (error: any) {
const msg = extractErrorString(error);
multiStepToast.setFailed(msg);
Expand Down

1 comment on commit ab6acad

@vercel
Copy link

@vercel vercel bot commented on ab6acad Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.