Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions apps/dashboard/src/@/analytics/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,39 @@ export function reportAssetPageview(properties: {
}) {
posthog.capture("asset pageview", properties);
}

/**
* ### Why do we need to report this event?
* - To track the usage of fund wallet modal
* - To create a funnel "fund wallet modal opened" -> "fund wallet buy successful" to understand the conversion rate
*
* ### Who is responsible for this event?
* @MananTank
*/
export function reportFundWalletOpened() {
posthog.capture("fund wallet opened");
}

/**
* ### Why do we need to report this event?
* - To track the number of successful fund wallet buys
* - To create a funnel "fund wallet modal opened" -> "fund wallet buy successful" to understand the conversion rate
*
* ### Who is responsible for this event?
* @MananTank
*/
export function reportFundWalletSuccessful() {
posthog.capture("fund wallet successful");
}

/**
* ### Why do we need to report this event?
* - To track the number of failed fund wallet buys
* - To track the errors that users encounter when trying to buy from a fund wallet modal
*
* ### Who is responsible for this event?
* @MananTank
*/
export function reportFundWalletFailed(params: { errorMessage: string }) {
posthog.capture("fund wallet failed", params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import type { ThirdwebClient } from "thirdweb";
import { defineChain } from "thirdweb/chains";
import { CheckoutWidget, useActiveWalletChain } from "thirdweb/react";
import { z } from "zod";
import {
reportFundWalletFailed,
reportFundWalletSuccessful,
} from "@/analytics/report";
import { SingleNetworkSelector } from "@/components/blocks/NetworkSelectors";
import { TokenSelector } from "@/components/blocks/TokenSelector";
import { Button } from "@/components/ui/button";
Expand Down Expand Up @@ -252,6 +256,14 @@ function FundWalletModalContent(props: FundWalletModalProps) {
className="!w-full !max-w-full !min-w-0 !rounded-b-none !border-none"
theme={getSDKTheme(theme === "dark" ? "dark" : "light")}
name={props.checkoutWidgetTitle}
onSuccess={() => {
reportFundWalletSuccessful();
}}
onError={(error) => {
reportFundWalletFailed({
errorMessage: error.message,
});
}}
/>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { toast } from "sonner";
import { getAddress, type ThirdwebClient } from "thirdweb";
import { isAddress, shortenAddress } from "thirdweb/utils";
import { z } from "zod";
import { reportFundWalletOpened } from "@/analytics/report";
import { FundWalletModal } from "@/components/blocks/fund-wallets-modal";
import { TWTable } from "@/components/blocks/TWTable";
import { WalletAddress } from "@/components/blocks/wallet-address";
Expand Down Expand Up @@ -268,6 +269,7 @@ export const BackendWalletsTable: React.FC<BackendWalletsTableProps> = ({
onClick: (wallet) => {
setSelectedBackendWallet(wallet);
setReceiveOpen(true);
reportFundWalletOpened();
},
text: "Fund wallet",
},
Expand Down
Loading